Skip to main content
added 88 characters in body
Source Link
Ryan Shea
  • 776
  • 8
  • 12

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

Note: make sure that you have already indexed the blockchain or else this might not work. To index, restart bitcoind with txindex=1 as a config variable.

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the output of this new tx where the value n is equal to the vout of our original tx
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

We now have:

"scriptPubKey" : {
    "asm" : "OP_DUP OP_HASH160 17492e77be2c666af78993020b90235cd1d3738d OP_EQUALVERIFY OP_CHECKSIG",
    "hex" : "76a91417492e77be2c666af78993020b90235cd1d3738d88ac",
    "reqSigs" : 1,
    "type" : "pubkeyhash",
    "addresses" : [
        "1388D9sHH4HXdGLxkSipxe2noZuekHZmaF"
    ]
}

and the sender is 1388D9sHH4HXdGLxkSipxe2noZuekHZmaF

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if the field has two components separated by a space, and the second component is a valid public key, then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

We see that there is in fact a valid pubkey in the original tx scriptSig:

02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9

We use coinkitCoinkit to extract the address:

$ sudo pip install coinkit
$ python
>>> from coinkit import *BitcoinPublicKey
>>> pub = BitcoinPublicKey('02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9')
>>> pub.address()
'1388D9sHH4HXdGLxkSipxe2noZuekHZmaF'

And we have the same answer!

P.S. you can inspect the Coinkit library I used above on github

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

Note: make sure that you have already indexed the blockchain or else this might not work. To index, restart bitcoind with txindex=1 as a config variable.

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the output of this new tx where the value n is equal to the vout of our original tx
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

We now have:

"scriptPubKey" : {
    "asm" : "OP_DUP OP_HASH160 17492e77be2c666af78993020b90235cd1d3738d OP_EQUALVERIFY OP_CHECKSIG",
    "hex" : "76a91417492e77be2c666af78993020b90235cd1d3738d88ac",
    "reqSigs" : 1,
    "type" : "pubkeyhash",
    "addresses" : [
        "1388D9sHH4HXdGLxkSipxe2noZuekHZmaF"
    ]
}

and the sender is 1388D9sHH4HXdGLxkSipxe2noZuekHZmaF

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if the field has two components separated by a space, and the second component is a valid public key, then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

We see that there is in fact a valid pubkey in the original tx scriptSig:

02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9

We use coinkit to extract the address:

$ sudo pip install coinkit
$ python
>>> from coinkit import *
>>> pub = BitcoinPublicKey('02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9')
>>> pub.address()
'1388D9sHH4HXdGLxkSipxe2noZuekHZmaF'

And we have the same answer!

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

Note: make sure that you have already indexed the blockchain or else this might not work. To index, restart bitcoind with txindex=1 as a config variable.

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the output of this new tx where the value n is equal to the vout of our original tx
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

We now have:

"scriptPubKey" : {
    "asm" : "OP_DUP OP_HASH160 17492e77be2c666af78993020b90235cd1d3738d OP_EQUALVERIFY OP_CHECKSIG",
    "hex" : "76a91417492e77be2c666af78993020b90235cd1d3738d88ac",
    "reqSigs" : 1,
    "type" : "pubkeyhash",
    "addresses" : [
        "1388D9sHH4HXdGLxkSipxe2noZuekHZmaF"
    ]
}

and the sender is 1388D9sHH4HXdGLxkSipxe2noZuekHZmaF

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if the field has two components separated by a space, and the second component is a valid public key, then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

We see that there is in fact a valid pubkey in the original tx scriptSig:

02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9

We use Coinkit to extract the address:

$ sudo pip install coinkit
$ python
>>> from coinkit import BitcoinPublicKey
>>> pub = BitcoinPublicKey('02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9')
>>> pub.address()
'1388D9sHH4HXdGLxkSipxe2noZuekHZmaF'

And we have the same answer!

P.S. you can inspect the Coinkit library I used above on github

added 961 characters in body
Source Link
Ryan Shea
  • 776
  • 8
  • 12

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

Note: make sure that you have already indexed the blockchain or else this might not work. To index, restart bitcoind with txindex=1 as a config variable.

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the nth output of this new tx where n = voutthe value n is equal to the vout of our original tx
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

Method B (faster but only works for certain types of transactions)We now have:

"scriptPubKey" : {
    "asm" : "OP_DUP OP_HASH160 17492e77be2c666af78993020b90235cd1d3738d OP_EQUALVERIFY OP_CHECKSIG",
    "hex" : "76a91417492e77be2c666af78993020b90235cd1d3738d88ac",
    "reqSigs" : 1,
    "type" : "pubkeyhash",
    "addresses" : [
        "1388D9sHH4HXdGLxkSipxe2noZuekHZmaF"
    ]
}

and the sender is 1388D9sHH4HXdGLxkSipxe2noZuekHZmaF

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if there'sthe field has two components separated by a space, and the second component is a valid public key in there[1], then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

[1] if the field has two components separated byWe see that there is in fact a space, andvalid pubkey in the second component is of length 130 or 66original tx scriptSig:

02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9

We use coinkit to extract the address:

$ sudo pip install coinkit
$ python
>>> from coinkit import *
>>> pub = BitcoinPublicKey('02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9')
>>> pub.address()
'1388D9sHH4HXdGLxkSipxe2noZuekHZmaF'

And we have the same answer!

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the nth output where n = vout
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if there's a valid public key in there[1], then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

[1] if the field has two components separated by a space, and the second component is of length 130 or 66

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

Note: make sure that you have already indexed the blockchain or else this might not work. To index, restart bitcoind with txindex=1 as a config variable.

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the output of this new tx where the value n is equal to the vout of our original tx
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

We now have:

"scriptPubKey" : {
    "asm" : "OP_DUP OP_HASH160 17492e77be2c666af78993020b90235cd1d3738d OP_EQUALVERIFY OP_CHECKSIG",
    "hex" : "76a91417492e77be2c666af78993020b90235cd1d3738d88ac",
    "reqSigs" : 1,
    "type" : "pubkeyhash",
    "addresses" : [
        "1388D9sHH4HXdGLxkSipxe2noZuekHZmaF"
    ]
}

and the sender is 1388D9sHH4HXdGLxkSipxe2noZuekHZmaF

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if the field has two components separated by a space, and the second component is a valid public key, then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

We see that there is in fact a valid pubkey in the original tx scriptSig:

02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9

We use coinkit to extract the address:

$ sudo pip install coinkit
$ python
>>> from coinkit import *
>>> pub = BitcoinPublicKey('02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9')
>>> pub.address()
'1388D9sHH4HXdGLxkSipxe2noZuekHZmaF'

And we have the same answer!

Source Link
Ryan Shea
  • 776
  • 8
  • 12

Each transaction can have multiple inputs and thus can have multiple senders.

Here's how you get the sender(s):

bitcoin-cli getrawtransaction 8386a8d2870c0df79f652ef4d981b21649ebf40601948c1c0709de0f02de8c8c 1

(the 1 flag indicates that you want the raw tx to be decoded)

From that, you get a fairly big response, which contains the following:

"vin" : [{
    "txid" : "5203d1db5eeef77de7c404ec14487892e3dd12b4a562537243533a169d45753c",
    "vout" : 1,
    "scriptSig" : {
        "asm" : "304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca01 02be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9",
        "hex" : "47304402200ee65c9f757eb6c240efe5a7e4427e04174a32da14b1eef459d36d61d031f6e702202d6b5383f86f155d92a494e80a1242af7e160faf16d597ea457b6e3bf08bb1ca012102be7759e73363488269f0257158177f3295af42d1f3a6b2fdf8fb4380b1d16ae9"
    },
    "sequence" : 4294967295
}]

This means there's a single input, so there is in fact one sender.

Now, there are two ways to get the sender.

Method A (should always work but is slower):

  1. grab the txid and the vout
  2. do bitcoin-cli getrawtransaction <txid> 1
  3. find the nth output where n = vout
  4. go to the scriptPubKey section and check the hex or addresses field - that's the sender (in hex pubkey script or address form)

Method B (faster but only works for certain types of transactions):

  1. check the 'asm' field inside the 'scriptSig' field
  2. if there's a valid public key in there[1], then we have a standard pay-to-pubkey(-hash) transaction, so convert the pubkey to an address
  3. fallback to method A

[1] if the field has two components separated by a space, and the second component is of length 130 or 66