Anyway, I'm actually trying to implement both ways. "One address" and "Generate unique addresses". Just to see how they compare. While testing this with one address, I noticed that sometimes I don't seem to get the sending address from first offset in the input. See my testing here:
http://api.blockcypher.com/v1/btc/test3/addrs/mggchBoqRNoT3beYCX4h2DMGtT2a6AaFFg
I've send a few testnet3 bitcoins to the mggchBoqRNoT3beYCX4h2DMGtT2a6AaFFg address, and if you look at the this transaction here: https://api.blockcypher.com/v1/btc/test3/txs/2e11ff66366592fdca419baef8873532594d85d80de5b3f714cbcc301eda3c20
I can grab the correct sending address from this input:
{
"prev_hash": "25199d78f200daf77adc7e53883159fc57493d285c1cec0666136d84ece33ada",
"output_index": 1,
"script": "473044022060852275011e0eccf2b1418ab934a71456013408b128bbd44b5819069d9c220102200db6362b8bbbb805beb4463cc4a80d6374a18fc700561d903b9ace55fbf8ac47012103832dc693149e4b10cd8f40b1d54300a26892288c0725cb9a28c0fe07c1316c04",
"output_value": 9990000,
"sequence": 4294967295,
"addresses": [
"n295M4YJiumNFiTasqcHp5g7zr6BhD8G9L"
],
"script_type": "pay-to-pubkey-hash"
}
],
I get the sending address n295M4YJiumNFiTasqcHp5g7zr6BhD8G9L. All fine and dandy. This works for the other transactions as well, but when I look at this one: https://api.blockcypher.com/v1/btc/test3/txs/bd5d6f2a606f45be09c28744bc3b707bc885ee6f5ca0bd5e90ff54c0159b958c
The sending address is n4VQ5YdHf7hLQ2gWQYYrcxoE5B7nWuDFNF for some reason. And I have no idea why.
{
"prev_hash": "2e11ff66366592fdca419baef8873532594d85d80de5b3f714cbcc301eda3c20",
"output_index": 0,
"script": "4730440220614eda9788afbbe4bc2f51bb36adbdfbff6c530ac8907dd83d47008abfcb5abb02202ee62383e2b3561416ee5c0f7eb1aa5a69d4feaa2833fa11e801b41def894ed3012103fee3aa600f2edd4048731b47fc976b8b8cc28afc4ae115b8af02956e71133350",
"output_value": 4980000,
"sequence": 4294967295,
"addresses": [
"n4VQ5YdHf7hLQ2gWQYYrcxoE5B7nWuDFNF"
],
"script_type": "pay-to-pubkey-hash"
}
],
I only have these receiving (sending) addresses in the wallet:
mtPw16eSgDNojw5w7VEshLAk55nh8UCihZ
n295M4YJiumNFiTasqcHp5g7zr6BhD8G9L
msoZ1tjxth5Z6RDXKjPRTvES1QyGs2XkvR
So, as this seems tricky I'm now really leaning towards generating unique addresses instead. Anyone that can cast a light on this? If you look at the address here: https://live.blockcypher.com/btc-testnet/address/n4VQ5YdHf7hLQ2gWQYYrcxoE5B7nWuDFNF/ you can see it seems like the address just became some temporary receive and send address... Either way, it's confusing me.
I will continue working on "generate addresses" instead, as this "grabbing sending address" doesn't seem too reliable..