StarNeit
StarNeit

Reputation: 23

How to get sender bitcoin address from transaction ID?

I am using coinpayment.net payment API for my project now.

Here is example bitcoin transaction. https://www.blockchain.com/btc/tx/25ecdc29903aa8f80efb51a6b41ac036a91fe441aefd0d26df383827b9578cae

Here is transactionID is 25ecdc29903aa8f80efb51a6b41ac036a91fe441aefd0d26df383827b9578cae.

Sender address is bc1q3q2jw046t888slq9rrg6ypwfna7ellkxh0ytss

I want to get this sender address by programming with TxID.

If you have got any solution or API, please let me know.

I have checked coinpayments.net api, but they don't provide sender address somehow in webhook endpoint. So, I am trying to find out this by external api or any solution.

The purpose of this is that I want to send some BTC to sender again every month without asking withdraw address to every customers.

Upvotes: 2

Views: 2652

Answers (1)

Boris Ivanov
Boris Ivanov

Reputation: 4254

You can use any scripting language with JSON support like perl, JavaScript or python. Or simply use command line tool like jq:

curl -s https://blockchain.info/tx/25ecdc29903aa8f80efb51a6b41ac036a91fe441aefd0d26df383827b9578cae\?format\=json | jq '.inputs[0]."prev_out".addr'

to get familiar with jq use https://jqplay.org/

another way is to install your own bitcoin node and fetch all info directly from your own node.

Upvotes: 1

Related Questions