Author

Topic: [SOLVED] Sender-Address of ScriptSig (Read 3996 times)

sr. member
Activity: 475
Merit: 252
January 31, 2015, 07:39:46 AM
#10
Finally figured it out with bitcoinj ...

Code:
	private static String s="483045022001bef6b42a6a7cb4dfac6ce93982b0d0a0f3bf0fe55134c278e2a6726d11c596022100fec6b4acd6364007334ec6359a5a5bdde055624824de5f8c0dca064564856f51012103a097b85e726f5e66232c33da2eca4bb0936d8d30a4c721abd0a1717cc5c06708";

public static byte[] hexStringToByteArray(String s) {
    int len = s.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i < len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                             + Character.digit(s.charAt(i+1), 16));
    }
    return data;
}

/**
* @param args
* @throws ScriptException
*/
public static void main(String[] args) throws ScriptException {
TransactionInput tin = new TransactionInput(NetworkParameters.testNet3(), null, hexStringToByteArray(s));
Address a = tin.getScriptSig().getFromAddress();
System.out.println(a.toString());
}

The code outputs correctly "mkMUgWeh3mfpgvKgjK81rUMqKfNoww7tie" (txid: 1d893276bcae417e39aa08b60d02c9b3d4d5e2380aba6bcf359b6d752923ae9f)

hey i have question

if sendAddress is multisig address(ex https://blockchain.info/tx/ad0c703eb06d9dd9556a160a8cfb318e666cc2baf44a95c826ce8bd0b2bcba9a)

this code available?

The same code should work with BitcoinJ. .getFromAddress() will return P2SH if the ScriptSig is P2SH
sr. member
Activity: 462
Merit: 251
January 31, 2015, 03:38:39 AM
#9
Finally figured it out with bitcoinj ...

Code:
	private static String s="483045022001bef6b42a6a7cb4dfac6ce93982b0d0a0f3bf0fe55134c278e2a6726d11c596022100fec6b4acd6364007334ec6359a5a5bdde055624824de5f8c0dca064564856f51012103a097b85e726f5e66232c33da2eca4bb0936d8d30a4c721abd0a1717cc5c06708";

public static byte[] hexStringToByteArray(String s) {
    int len = s.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i < len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                             + Character.digit(s.charAt(i+1), 16));
    }
    return data;
}

/**
* @param args
* @throws ScriptException
*/
public static void main(String[] args) throws ScriptException {
TransactionInput tin = new TransactionInput(NetworkParameters.testNet3(), null, hexStringToByteArray(s));
Address a = tin.getScriptSig().getFromAddress();
System.out.println(a.toString());
}

The code outputs correctly "mkMUgWeh3mfpgvKgjK81rUMqKfNoww7tie" (txid: 1d893276bcae417e39aa08b60d02c9b3d4d5e2380aba6bcf359b6d752923ae9f)

hey i have question

if sendAddress is multisig address(ex https://blockchain.info/tx/ad0c703eb06d9dd9556a160a8cfb318e666cc2baf44a95c826ce8bd0b2bcba9a)

this code available?



legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
April 22, 2013, 04:35:11 AM
#8
You mean the bitcoin network flooding of small-ammount transactions? Smiley

Yes - without wanting to get into the debate about scalability it serves little useful purpose to be sending 1 satoshi "signals" through the blockchain.
newbie
Activity: 19
Merit: 0
April 22, 2013, 03:52:05 AM
#7
That's very interesting ... As I know, satoshidice does exactly the same ... They send the won bitcoins to the sender address back.

I havn't heared of any problems yet ... Do you know more you could tell me about?

There have been a few topics raised by people who sent money from a Mt. Gox (or other similar) account to SD which means the returns went to Mt. Gox rather than the user (and apparently there are warnings on the SD page about not using web wallets).

Okay, understood ... This will make my engine much more easier, because I don't have to keep a full transaction index and I don't have to watch my transaction list ...

It's often the case that something is quite difficult to solve when choosing an unnatural way to solve the problem ...


Quote
Yes - that would be the much preferred approach (and *please* don't send back 1 satoshi + fee *signals* like SD does when you lose).

You mean the bitcoin network flooding of small-ammount transactions? Smiley
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
April 21, 2013, 09:59:46 PM
#6
That's very interesting ... As I know, satoshidice does exactly the same ... They send the won bitcoins to the sender address back.

I havn't heared of any problems yet ... Do you know more you could tell me about?

There have been a few topics raised by people who sent money from a Mt. Gox (or other similar) account to SD which means the returns went to Mt. Gox rather than the user (and apparently there are warnings on the SD page about not using web wallets).

*edit*: ah, here is a interesting discussion about ... it seems you are very right and I should give the opportunity to specify an address to which the money is sent after being processed by my engine ...

https://bitcointalk.org/index.php?topic=77870.120

Yes - that would be the much preferred approach (and *please* don't send back 1 satoshi + fee *signals* like SD does when you lose).
newbie
Activity: 19
Merit: 0
April 21, 2013, 03:00:56 PM
#5
Also understand that in general for people using web wallets the UTXO source addresses are *not* their own addresses at all (so sending back to them would actually just be sending money to the service rather than a user of it).


That's very interesting ... As I know, satoshidice does exactly the same ... They send the won bitcoins to the sender address back.

I havn't heared of any problems yet ... Do you know more you could tell me about?

This "sending back to sender" is crucial for my development project and it would be good to hear of problems in advance Smiley

*edit*: ah, here is a interesting discussion about ... it seems you are very right and I should give the opportunity to specify an address to which the money is sent after being processed by my engine ...

https://bitcointalk.org/index.php?topic=77870.120
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
April 21, 2013, 08:18:06 AM
#4
Also understand that in general for people using web wallets the UTXO source addresses are *not* their own addresses at all (so sending back to them would actually just be sending money to the service rather than a user of it).
kjj
legendary
Activity: 1302
Merit: 1026
April 21, 2013, 08:07:56 AM
#3
You are setting yourself up for trouble.  Bitcoin contains no concept of a "sender".
newbie
Activity: 19
Merit: 0
April 21, 2013, 04:17:00 AM
#2
Finally figured it out with bitcoinj ...

Code:
	private static String s="483045022001bef6b42a6a7cb4dfac6ce93982b0d0a0f3bf0fe55134c278e2a6726d11c596022100fec6b4acd6364007334ec6359a5a5bdde055624824de5f8c0dca064564856f51012103a097b85e726f5e66232c33da2eca4bb0936d8d30a4c721abd0a1717cc5c06708";

public static byte[] hexStringToByteArray(String s) {
    int len = s.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i < len; i += 2) {
        data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                             + Character.digit(s.charAt(i+1), 16));
    }
    return data;
}

/**
* @param args
* @throws ScriptException
*/
public static void main(String[] args) throws ScriptException {
TransactionInput tin = new TransactionInput(NetworkParameters.testNet3(), null, hexStringToByteArray(s));
Address a = tin.getScriptSig().getFromAddress();
System.out.println(a.toString());
}

The code outputs correctly "mkMUgWeh3mfpgvKgjK81rUMqKfNoww7tie" (txid: 1d893276bcae417e39aa08b60d02c9b3d4d5e2380aba6bcf359b6d752923ae9f)
newbie
Activity: 19
Merit: 0
April 21, 2013, 03:57:48 AM
#1
Hi all,

I've been fighting with jsonrpc and bitcoind for about 2 days ...  Sad

I still have the problem that I can't determine the sender address of received payments.

One easy solution would have been to simple grab the VOut of the previos transaction and extract the sender from there but bitcoind doesn't save transactions for which there are no private keys in the wallet. And I didn't figure out how I could motivate bitcoind to ask the p2p-network for details to a transaction with hash=X.

Currently, I know the pubkey of the sender has to be in scriptsig somewhere but it seems to be impossible to extract it from there.

After googling a lot, I didn't find any sample codes extracting the hash and converting it to a base58 address.

Coule someone please give me some tips?

Thank you in advance!

All the best,
Thomas
Jump to: