Get a list of txs that can be used for a newer tx

-1

I'd like to write a simple Bitcoin client that broadcast transactions. The model is pretty simple:

Alice wants to send 10 BTC to Bob. We only know Alice's private key and Bob's address.

For making the transaction, I need to collect enough Alice's previous transactions up to 10 BTC.

I've found the Blockchain Data API, that can be queried using Alice's address (which I can derive from Alice's private key, which is known by the client).

If I GET the API above using

$ curl -L http://blockchain.info/address/<Alice's address>?format=json&sort=<[01]>

I'll be returned with a JSON containing the whole list of transactions.

How should I use this result for collecting all the Alice's transactions that can be used in a newer transaction?

Giuseppe Crinò

Posted 2014-11-25T08:42:45.860

Reputation: 101

1What is the question? You should write a program, which parses the result, creates transaction from Alice to Bob, signs it with Alice's private key and broadcasts it to a network.amaclin 2014-11-25T11:15:42.317

1I'm not sure this is a question or a request to do the development for them. You need to be much more specific about what it is you are having problems with. "A bitcoin client" is not the problem you are having.T9b 2014-11-25T13:12:16.387

Answers

1

You will want to use the listunspent call from the blockchain.info API

http://blockchain.info/unspent?active=$address

This will give you a list of all unspent outputs at that address which are available to be used in a transaction.

You will then need to build a raw transaction to spend those outputs.

https://en.bitcoin.it/wiki/Raw_Transactions

Mullick

Posted 2014-11-25T08:42:45.860

Reputation: 74