Bitcoin Forum
November 10, 2024, 10:03:11 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [SOLVED] Sender-Address of ScriptSig  (Read 4003 times)
mnemonix (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 21, 2013, 07:57:48 AM
Last edit: April 21, 2013, 08:17:14 AM by mnemonix
 #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
mnemonix (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 21, 2013, 08: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)
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
April 21, 2013, 12:07:56 PM
 #3

You are setting yourself up for trouble.  Bitcoin contains no concept of a "sender".

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
April 21, 2013, 12:18:06 PM
 #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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
mnemonix (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 21, 2013, 07:00:56 PM
Last edit: April 21, 2013, 07:16:46 PM by mnemonix
 #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
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
April 22, 2013, 01:59:46 AM
 #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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
mnemonix (OP)
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
April 22, 2013, 07: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
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
April 22, 2013, 08: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.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
myohmy81
Sr. Member
****
Offline Offline

Activity: 462
Merit: 251


View Profile
January 31, 2015, 07: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?



dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
January 31, 2015, 11: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

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!