Closed Mandelhoff closed 6 years ago
The light wallet does the spend_tx with 2 http requests. Here is the first: https://github.com/zack-bitcoin/amoveo/blob/master/apps/ae_http/priv/external_web/spend_tx.js#L30
Here is the second: https://github.com/zack-bitcoin/amoveo/blob/master/apps/ae_http/priv/external_web/spend_tx.js#L56
Only the 2nd is necessary.
The first request gives the server some info about what you want to put in the tx. The server generates the tx and sends it back to you.
Then you verify it is formatted how you expected, you sign it, and you use the second http request to give it back to the server.
You don't have to let the server generate the tx, you can do it yourself in javascript and then just use the 2nd http request to push the signed tx to the server.
Here is an example of accessing the api from curl: https://github.com/zack-bitcoin/amoveo/blob/master/apps/ae_http/src/ext_handler.erl#L8
In case I'm going about this all wrong - my goal is to remotely make payments programatically (no Erlang prompt and no Light Wallet UI).
The mining pool is able to make payments automatically. It is using the internal api of a full node on the same machine.
If you want to securely make payments, you either need to have a full node or a light node running somewhere, and you need to be able to securely communicate with that node. It is easiest to have the node on the same machine.
If you decide to generate the tx on your own without the server's help, you would have to look up and verify 2 things from the consensus state. Your account state, and the person who you are sending money to's account state. So it would take an extra http request and move more data around if you decide to generate the tx on your own instead of letting the server generate it.
Thanks. I've got a few more things to try after a million dead ends on this today.
I couldn't get the .Net secp256k1 cryptography to generate the public key and "sign" the same way as your javascript, and it was driving me crazy.
Yes. I remember rewriting the signature library from erlang to javascript
I can do a spend_tx from the Erlang prompt, and I can do a spent_tx from the Light Wallet. I would like to do a spend_tx from a REST based command like curl.
I see the json sent via the light wallet. When I try to reproduce this with curl or c# or c++, I get a server 500 error.
The json in this screenshot appears to just be pub keys, so I'm guessing the priv key comes in to play somewhere and somehow that I'm not observing.
In case I'm going about this all wrong - my goal is to remotely make payments programatically (no Erlang prompt and no Light Wallet UI).