Pages:
Author

Topic: Is there an import/export transaction patch? - page 2. (Read 7060 times)

legendary
Activity: 2053
Merit: 1354
aka tonikt
Today I improved the GUI a bit. Now it isn't a hack anymore, but a proper user interface.

To export a transaction made in an offline client, you double click on it in the main window.
When the transaction info pops up there will be the additional button "Export".
After clicking the button a "Save File" dialog will open - specify the folder where you want to save the transaction file (USB disk, I assume, unless you still use floppies Tongue)




For importing there is a new menu option Settings/Import transaction...
After choosing it "Open File" dialog will show up, so point it to the file you created before.



Moreover, if you try to re-import a transaction that already got into the blockchain, you will be notified (so you know you don't really need to do it).




It actually works quite nice. At least as far as I could test it.
So I committed it to the same branch.
https://github.com/piotrnar/bitcoin-impexptx


I figured that you could also use this functionality not necessarily for security reasons, but also for convenience.
For instance you make an appointment with someone to sell him bitcoins for cash.
He gives you his bitcoin address in advance, you backup your wallet, make the send transaction (just make sure to do it offline!!!) and export it into a file.
The next day you go to his house, he gives you the cash and you give him the file.
He imports the file into his client, you wait together for 2 blocks or so (suggest a bier during this time) to make sure that the transaction gets validated... and viola! You gave him bitcoins and didn't even need to bring your wallet along (except for the one to store the cash you got).
And if the transaction doesn't happen (because you realized that the guy wanted to screw you over) you just destroy the file and recover the backup of the wallet.
This way you can sell your bitcoins without even having access to internet Smiley
legendary
Activity: 2053
Merit: 1354
aka tonikt
Yay! There is also a patch for a 'getrawtransaction' command which can be used to check for confirmations, instead of blockexplorer.
https://github.com/forrestv/bitcoin/tree/getrawtransaction
That would indeed be a better option, rather than fetching data from Block Explorer.
member
Activity: 73
Merit: 10
Yay! There is also a patch for a 'getrawtransaction' command which can be used to check for confirmations, instead of blockexplorer.
https://github.com/forrestv/bitcoin/tree/getrawtransaction
full member
Activity: 154
Merit: 100
Cool, can't wait to try this Smiley
member
Activity: 73
Merit: 10
Ah, of course! It returns the txid on import... Then it's easy of course. Missed that Smiley
legendary
Activity: 2053
Merit: 1354
aka tonikt
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...
member
Activity: 73
Merit: 10
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?
legendary
Activity: 2053
Merit: 1354
aka tonikt
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.
member
Activity: 73
Merit: 10
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.
XIU
member
Activity: 84
Merit: 10
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.
legendary
Activity: 2053
Merit: 1354
aka tonikt
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
XIU
member
Activity: 84
Merit: 10
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
legendary
Activity: 2053
Merit: 1354
aka tonikt
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
XIU
member
Activity: 84
Merit: 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

But then you still bring your complete wallet in an online, potentially dangerous, environment.
hero member
Activity: 767
Merit: 500
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
legendary
Activity: 1400
Merit: 1005
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
legendary
Activity: 2053
Merit: 1354
aka tonikt
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
member
Activity: 73
Merit: 10
I believe for someone familiar with the code this shouldn't be too hard (?)

Why not start a bounty? I'll pledge 1BTC.
legendary
Activity: 2053
Merit: 1354
aka tonikt
that would work.
but import/export of a private key seems equally complicated
XIU
member
Activity: 84
Merit: 10
How about being able to make a payment on your offline account to a new address, then exporting that private key?
Pages:
Jump to: