Bitcoin Forum
March 19, 2024, 03:09:23 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: Is there an import/export transaction patch?  (Read 7060 times)
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 12, 2011, 06:24:11 PM
Last edit: November 08, 2011, 07:36:50 PM by piotr_n
 #1

I got paranoid and I moved my savings wallet to a separate PC that has a bitcoin client (so I can check my account's balance), but is never to be connected to the network. I just bring the blockchain there on a flash disk and use the client with the -rescan switch.
But this is more of a read-only mode, just to check my balance.
Money is nothing if you cannot spend it.
So since I am already so paranoid, I am wondering now: how am I going to spend that money without connecting my wallet to the internet?

Has anyone created a way to export a signed transaction from an offline bitcoin client into a file, and then import this transaction into an online client (obviously without the wallet), so it would get broadcasted to the network?

Is there any patch/forked source tree, which does that?
I can deal with the source code - no problem.
Just don't want o re-invent the wheel, if someone has done it already.

EDIT:
If you want to try this patch: https://github.com/piotrnar/bitcoin-impexptx
How to use it: https://bitcointalk.org/index.php?topic=28278.msg383312#msg383312

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
1710817763
Hero Member
*
Offline Offline

Posts: 1710817763

View Profile Personal Message (Offline)

Ignore
1710817763
Reply with quote  #2

1710817763
Report to moderator
1710817763
Hero Member
*
Offline Offline

Posts: 1710817763

View Profile Personal Message (Offline)

Ignore
1710817763
Reply with quote  #2

1710817763
Report to moderator
1710817763
Hero Member
*
Offline Offline

Posts: 1710817763

View Profile Personal Message (Offline)

Ignore
1710817763
Reply with quote  #2

1710817763
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1710817763
Hero Member
*
Offline Offline

Posts: 1710817763

View Profile Personal Message (Offline)

Ignore
1710817763
Reply with quote  #2

1710817763
Report to moderator
1710817763
Hero Member
*
Offline Offline

Posts: 1710817763

View Profile Personal Message (Offline)

Ignore
1710817763
Reply with quote  #2

1710817763
Report to moderator
drrussellshane
Hero Member
*****
Offline Offline

Activity: 546
Merit: 500


View Profile
July 12, 2011, 06:31:44 PM
 #2

You would connect your savings wallet computer to the internet long enough to send your coins, then create a new secure offline wallet for the rest of the coins.

A bit cumbersome, but safety is often that way.

Buy a TREZOR! Premier BTC hardware wallet. If you're reading this, you should probably buy one if you don't already have one. You'll thank me later.
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 12, 2011, 06:59:14 PM
 #3

Thanks, that's what I was thinking of if I eventually have no other choice.
But there must be a way... this system is not that complex. Since I'm not in a hurry here I'd rather prefer to create such a patch myself, instead of stressing myself in an online mode.
Just checking if maybe it's just unnecessary.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
SgtSpike
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
July 12, 2011, 07:02:09 PM
 #4

I'm interested in such a patch as well, should one become available.
XIU
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile WWW
July 13, 2011, 07:12:52 PM
 #5

How about being able to make a payment on your offline account to a new address, then exporting that private key?
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 13, 2011, 07:14:32 PM
 #6

that would work.
but import/export of a private key seems equally complicated

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
riush
Member
**
Offline Offline

Activity: 73
Merit: 10


View Profile
July 13, 2011, 07:20:06 PM
 #7

I believe for someone familiar with the code this shouldn't be too hard (?)

Why not start a bounty? I'll pledge 1BTC.

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 13, 2011, 07:24:00 PM
 #8

Why not start a bounty? I'll pledge 1BTC.
ok, I'll take it. unless someone familiar with the code will get there sooner Smiley

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
SgtSpike
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
July 13, 2011, 08:34:25 PM
 #9

Why not start a bounty? I'll pledge 1BTC.
ok, I'll take it. unless someone familiar with the code will get there sooner Smiley
Excellent!  I'm looking forward to seeing the patch.  Smiley
willphase
Hero Member
*****
Offline Offline

Activity: 767
Merit: 500


View Profile
July 13, 2011, 10:13:02 PM
 #10

I keep my wallet.dat offline on an encrypted usb stick, and check my balance using my android app which allows me read only real-time access (no need to download block chain) to my wallet balance/transactions with just my public addresses.  This allows me to verify e.g. pool payments are working okay, and when/if I want to actually make a payment I mount my usb stick to make the payment.  See my sig for the app - YMMV.

Will

XIU
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile WWW
July 14, 2011, 09:02:41 AM
 #11

I keep my wallet.dat offline on an encrypted usb stick, and check my balance using my android app which allows me read only real-time access (no need to download block chain) to my wallet balance/transactions with just my public addresses.  This allows me to verify e.g. pool payments are working okay, and when/if I want to actually make a payment I mount my usb stick to make the payment.  See my sig for the app - YMMV.

Will

But then you still bring your complete wallet in an online, potentially dangerous, environment.
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 17, 2011, 03:15:45 PM
Last edit: November 08, 2011, 07:51:18 PM by piotr_n
 #12

I have added it to my client - no problem to export a transaction, but importing it into an online node is a bit tricky...

From what I see the node does not re-broadcast transactions which do not originate from its own wallet.
So the transaction gets broadcasted once (while you're importing it), but then never re-broadcasted.

The good thing is that you can always import the same transaction again to get it re-broadcasted (if you see that it hasn't been noted by the network). But this is obviously not a user friendly solution so I'm not pushing this.
I'm thinking how to improve it, but it seems that making it robust would require lots of changes all around the source code.
Any ideas welcome.


Anyway, if anyone needs such a function, the patch is ready.
Except the issues I've mentioned, it seems to do the job well - as for me the security it gives me is worth the additional hassle.
And the changes are quite simple, very easy to review.
Depending if you prefer RPC or UI - you need to modify one of the cpp files.
If you plan to use only the UI method you don't need to patch the rpc.cpp file - and vice versa.
https://github.com/piotrnar/bitcoin-impexptx


Just a quick manual.

So after you sent some coins using the standard interface in your offline client you need to export the transaction from here and import it into an online client.
You can choose one of the two methods:

1. The UI method.
Double click on the sent transaction which you want to export, the popup opens and the raw transaction data (base58 encoded) gets copied to your clipboard. Just close the popup - the data will be in Clipboard.
So you need to transfer the content of the clipboard to the online PC, then click on "Send Coins" and paste the raw transaction data into the "Pay To" field. Leave the amount empty and click "Send".

2. The RPC method.
"gettransaction" returns now an additional field "rawdata" - the value of this field is what you need to move to the online PC. It is of course the same value that would get copied to Clipboard if using the UI method.
In the online PC there is a new API command "importtransacion" - execute it with only one parameter, which is the "rawdata" value returned by "gettransaction" in the offline PC.

In both cases every time you re-import, the transaction should get re-broadcasted.
So you should definitely redo it if you see that it hasn't been confirmed after a few blocks.

The "rawdata" string is just a base58 encoded binary dump of the transaction (from "version" to "lock time" - both inclusive).

That's it - have fun Smiley

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
XIU
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile WWW
July 18, 2011, 01:16:23 PM
 #13

Nice work, so the thing we want eventually is an "Make offline payment" (aka export the transaction), then on another wallet/client "Publish offline payment" (aka import transaction and rebroadcast) Smiley
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 18, 2011, 01:21:02 PM
Last edit: July 18, 2011, 08:24:32 PM by piotr_n
 #14

Sort of.
But you don't really need to "Make offline payment"
You just do a traditional payment, but since the client is disconnected from the network you need to transfer its content by other means, not via a network.
And then "Publish offline payment" - sound like a catchy term Smiley

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
XIU
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile WWW
July 18, 2011, 01:34:08 PM
 #15

Sort of.
But you don't really need to "Make offline payment"
You just to a traditional payment, but since the client is disconnected from the network you need to transfer it's content by other means, not via a network.
And then "Publish offline payment" - sound like a catchy term Smiley

Yeah, the make offline payment would give you the export directly.
riush
Member
**
Offline Offline

Activity: 73
Merit: 10


View Profile
July 18, 2011, 09:33:57 PM
 #16

Very nice, great work!
Just tested the rpc calls on testnet and everything works fine Cheesy

Tell me a bitcoin address and you'll get your promised coin.

Now I just have to figure out the new WX version, haven't built the gui in a while...
I also think this probably isn't very intuitive for a 'normal' user; maybe have an 'export transaction' button in the send dialog which asks for a file to write the rawdata to.
Then an 'import transaction' button somewhere (in the menu?) which lets one choose a file. But that's definitely optional, my personal use-case is satisfied.

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 19, 2011, 06:44:03 AM
Last edit: November 08, 2011, 07:51:30 PM by piotr_n
 #17

I'm glad you like it.

Yes, the UI method is a bit of a hack, but since I was expecting trust issues here I though it would be better to change as little as possible.
But if you like it I will add buttons - should be fun.

Maybe someone would like to setup a web service where you can paste a raw transaction to announce it into the bitcoin network.
That would be a nice thing and not really hard to implement - then the end user only needs the export part (in the offline client).
The service itself could take care of re-broadcasting, i.e. if the transaction does not show up in Block Explorer after some time.
I could create such a service, just don't have a server to run it on.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
riush
Member
**
Offline Offline

Activity: 73
Merit: 10


View Profile
July 19, 2011, 11:30:23 AM
 #18

Bitcoin is on its way.

You have a point with making the changes easy to review, but I think before this gets merged, the interface should be more obvious.
(Maybe I'm wrong here - could a core-dev comment his opinion on this?)

I was planning to integrate that into my online wallet, however I'm not very fond of decoding the rawdata myself...
If the user pastes the whole output of gettransaction it would be much easier, and maybe also a plus in usability; this way if you have multiple exported transactions, you can easily see which is which.
Could you maybe add that to the data the gui exports, and change the import so it accepts a json hash and just uses the 'rawdata' field of that?
Or do you think this is not a good idea and the webservice should just make the effort and decode it?

Edit: OTOH, if you make a standalone webservice for that, I would consider installing it on my server - if I can figure out how; what language/framework would you use?

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1344


aka tonikt


View Profile WWW
July 19, 2011, 12:37:11 PM
 #19

Got it - cheers!

I think the only thing that is worth merging ATM is the export part - it doesn't hurt and can be useful.
Import, as I said, is just not reliable and shouldn't get released in this form... Maybe after we make it reliable, so importing once would be enough.

Quote
I was planning to integrate that into my online wallet, however I'm not very fond of decoding the rawdata myself...
If the user pastes the whole output of gettransaction it would be much easier, and maybe also a plus in usability; this way if you have multiple exported transactions, you can easily see which is which.
The rest of the output of gettransaction is just useless for this.
Of course you can move everything to your online PC, but importing of the transaction will only use the rawdata anyway.
So why don't you just give it the rawdata only and spare the JSON-parsing part.

Quote
if you make a standalone webservice for that, I would consider installing it on my server - if I can figure out how; what language/framework would you use?
From the user's point of view, there will be a webform, textarea where he puts the raw tansaction data, clinks "Send" and that should do all the job he needs.

What happens inside?
There is a simple PHP script that stores the given rawdata in an SQL table.
The table has at least 3 columns:
1) rawdata
2) trid (will be returned by a first call to "importtransaction")
3) timestamp (when the last import was issued for this transaction)

In the background you have a cron function that kicks in every minute or so.
It looks into the SQL table and:
1) Immediately calls "importtransaction" for any transaction that has not been imported yet - sets trid and timestamp accordingly.
2) Checks http://blockexplorer.com/tx/XXXX to verify if any of the transactions imported before are already confirmed - if so: remove it from the table.
3) If a last time of a transaction is more than 30 minutes (and it is still in the table) - call "importtransaction" with it again, updating the timestamp  to the current time.

That's it - in reality its easier to implement than it sounds.

What you need is PHP, SQL and a running bitcoin server with the "importtransaction" patch.
But it doesn't need to be a secured node, because it does not store any money, only injects transactions into the network.

You could also think of making a simple command line tool that would connect to an existing bitcoin node (no need for "importtransaction" patch) and just announce the transaction using the standard bitcoin protocol. But I'm not sure how complex this solution would be, is there some handshake or something...

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
riush
Member
**
Offline Offline

Activity: 73
Merit: 10


View Profile
July 19, 2011, 12:58:48 PM
 #20

Ah, of course! It returns the txid on import... Then it's easy of course. Missed that Smiley

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!