Bitcoin Forum
May 26, 2024, 06:04:01 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: how to use wallet notify (bitcoind) ?  (Read 4121 times)
HackerBOSS (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 101


View Profile
April 27, 2016, 07:05:28 AM
 #21

If you potentially need to send refunds then the only correct way is to ask the user to provide a refund address at the time of payment.

The concept of a single guaranteed "from address" simply does not exist in bitcoin.

Quote
how resolve this problem?
what function rpc-api need use?

i need know sender wallet for refund amount..

that how works secondstrade.com ?

player send to address. if win that receive win to back. no need enter player address

shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
April 27, 2016, 08:12:44 AM
 #22

If you potentially need to send refunds then the only correct way is to ask the user to provide a refund address at the time of payment.

The concept of a single guaranteed "from address" simply does not exist in bitcoin.

Quote
how resolve this problem?
what function rpc-api need use?

i need know sender wallet for refund amount..

that how works secondstrade.com ?

player send to address. if win that receive win to back. no need enter player address

They guess and hope they are correct. If they are not, they blame the user for not reading #3 of their "how to play"[1]

[1] http://secondstrade.com/howtoplay.html

Im not really here, its just your imagination.
HackerBOSS (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 101


View Profile
April 27, 2016, 08:47:39 AM
 #23

If you potentially need to send refunds then the only correct way is to ask the user to provide a refund address at the time of payment.

The concept of a single guaranteed "from address" simply does not exist in bitcoin.

Quote
how resolve this problem?
what function rpc-api need use?

i need know sender wallet for refund amount..

that how works secondstrade.com ?

player send to address. if win that receive win to back. no need enter player address

They guess and hope they are correct. If they are not, they blame the user for not reading #3 of their "how to play"[1]

[1] http://secondstrade.com/howtoplay.html

but luckyb.it too, no need enter wallet..

i think that can get player wallet, but i don't know how..

do you have idea?

shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
April 27, 2016, 11:54:17 AM
 #24

If you potentially need to send refunds then the only correct way is to ask the user to provide a refund address at the time of payment.

The concept of a single guaranteed "from address" simply does not exist in bitcoin.

Quote
how resolve this problem?
what function rpc-api need use?

i need know sender wallet for refund amount..

that how works secondstrade.com ?

player send to address. if win that receive win to back. no need enter player address

They guess and hope they are correct. If they are not, they blame the user for not reading #3 of their "how to play"[1]

[1] http://secondstrade.com/howtoplay.html

but luckyb.it too, no need enter wallet..

i think that can get player wallet, but i don't know how..

do you have idea?

You cant get the users address from the blockchain, because the blockchain does not store user information. You can either guess like secondstrade etc. (bad) or ask the user. If you ask the user they will need accounts and passwords. That adds complexity to your service. Both are viable ways to handle this, depending who you ask. I personally think that the guesswork approach is a sign of a bad concept. You are transferring funds for other people, you should never have to guess where they want the funds to go.

Im not really here, its just your imagination.
danda
Full Member
***
Offline Offline

Activity: 201
Merit: 157


View Profile WWW
April 27, 2016, 10:26:43 PM
 #25

WARNING: This method can go wrong if the user sent from an exchange account or some other method that the user does not directly control, or if they sent an old-style multisig tx, or a non-standard tx.  It is NOT recommended.  But you asked.


The basic idea is to look at the first address entry of the vout structure of the first vin  of the transaction the user sent to you.
ie:  tx.vin[0].vout.addresses[0]

This is a little convoluted to obtain with stock bitcoind, because gettransactions does not include any vout.addresses field.

So we need to do it in two steps.

Step 1.

Code:
./bitcoin/src/bitcoin-cli getrawtransaction <txid> 1
Then you will see output like this:

Quote
{
    "txid" : "...",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "<first_vin_txid>",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "...",
                "hex" : "..."
            },
            "sequence" : 0
        },
        ...
}

Notice the vout in this case is 0.  So now, let's find the matching vout for <first_vin_txid>.

Step 2.

Code:
./bitcoin/src/bitcoin-cli getrawtransaction <first_vin_txid> 1

{
...
    "vout" : [
        {
            "value" : <amount>,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "...",
                "hex" : "...",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1GN..."
                ]
            }
        },
...

Ok, we find the vout where "n" matches "vout" from the vin we looked at in the orig transaction.  In this case "n" and "sequence" are both 0. Therefore 1GN... is the address associated with the first input of the orig transaction.  ie, this address contributed <amount> of funds.  Note that:

1) There may be one vin or multiple vin in the orig tx.  ie, outputs from multiple tx may have been consolidated into one.  It should be relatively safe to always choose the first vin.
2) There may be multiple values in the "addresses" field, eg if type = multisig.  in this case, you should probably abort.


again, don't do this.   ;-)

but luckyb.it too, no need enter wallet..

i think that can get player wallet, but i don't know how..

do you have idea?

mybitprices.info - wallet auditing   |  hd-wallet-derive - derive keys locally |  hd-wallet-addrs - find used addrs
lightning-nodes - list of LN nodes  |  coinparams - params for 300+ alts  |  jsonrpc-cli - cli jsonrpc client
subaddress-derive-xmr - monero offline wallet tool
HackerBOSS (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 101


View Profile
April 28, 2016, 04:38:00 AM
 #26

WARNING: This method can go wrong if the user sent from an exchange account or some other method that the user does not directly control, or if they sent an old-style multisig tx, or a non-standard tx.  It is NOT recommended.  But you asked.


The basic idea is to look at the first address entry of the vout structure of the first vin  of the transaction the user sent to you.
ie:  tx.vin[0].vout.addresses[0]

This is a little convoluted to obtain with stock bitcoind, because gettransactions does not include any vout.addresses field.

So we need to do it in two steps.

Step 1.

Code:
./bitcoin/src/bitcoin-cli getrawtransaction <txid> 1
Then you will see output like this:

Quote
{
    "txid" : "...",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "<first_vin_txid>",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "...",
                "hex" : "..."
            },
            "sequence" : 0
        },
        ...
}

Notice the vout in this case is 0.  So now, let's find the matching vout for <first_vin_txid>.

Step 2.

Code:
./bitcoin/src/bitcoin-cli getrawtransaction <first_vin_txid> 1

{
...
    "vout" : [
        {
            "value" : <amount>,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "...",
                "hex" : "...",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1GN..."
                ]
            }
        },
...

Ok, we find the vout where "n" matches "vout" from the vin we looked at in the orig transaction.  In this case "n" and "sequence" are both 0. Therefore 1GN... is the address associated with the first input of the orig transaction.  ie, this address contributed <amount> of funds.  Note that:

1) There may be one vin or multiple vin in the orig tx.  ie, outputs from multiple tx may have been consolidated into one.  It should be relatively safe to always choose the first vin.
2) There may be multiple values in the "addresses" field, eg if type = multisig.  in this case, you should probably abort.


again, don't do this.   ;-)

but luckyb.it too, no need enter wallet..

i think that can get player wallet, but i don't know how..

do you have idea?

OK, Thank you very much!

"2) There may be multiple values in the "addresses" field, eg if type = multisig.  in this case, you should probably abort."

If  multiple values in the "addresses" field, eg if type = multisig... Can i choose any address or first?

airezx20
Sr. Member
****
Offline Offline

Activity: 350
Merit: 250



View Profile
April 28, 2016, 07:55:53 AM
 #27

Looks like you are nearly done this project and i hope you can share it to me once you have done to make the script.. using json_rpc..
I really want to study it because i want to make a website dice game or lotto game in altcoin or crypto currency.. i hope that you can finished this and give me a sample of your work too.. Thanks..
danda
Full Member
***
Offline Offline

Activity: 201
Merit: 157


View Profile WWW
April 28, 2016, 08:07:51 AM
 #28

"2) There may be multiple values in the "addresses" field, eg if type = multisig.  in this case, you should probably abort."

If  multiple values in the "addresses" field, eg if type = multisig... Can i choose any address or first?

Well, you could, but it does not seem "correct".

Consider that a multisig transaction may have multiple signers.  As in, different people or businesses.  which is which?

The safest thing is to abort in this case, and follow up with user manually.   But you might not ever see this type of tx.

mybitprices.info - wallet auditing   |  hd-wallet-derive - derive keys locally |  hd-wallet-addrs - find used addrs
lightning-nodes - list of LN nodes  |  coinparams - params for 300+ alts  |  jsonrpc-cli - cli jsonrpc client
subaddress-derive-xmr - monero offline wallet tool
Pages: « 1 [2]  All
  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!