Author

Topic: return change to send address for coind (Read 810 times)

legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
April 15, 2016, 07:43:31 AM
#9
lol. another attempt at google and actually find an answer !!

Diamond Coin has exactly it Cheesy

https://github.com/DMDcoin/Diamond/commit/22f7eb608906d064cef043b45a2b5b17eb23f170#diff-d7618bdc04db23aa74d6a5a4198c58fd
legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
April 15, 2016, 07:19:59 AM
#8

Smiley
i'm still interested in finding a solution to this

legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
November 05, 2015, 09:19:35 AM
#7

sendmany and rawtransactions both take a bit of pissing around.

thanks for your suggestions,
but changin the code to send it straight back to an input address should be much simpler.  it wont require any extra analysis of the inputs at all, nor any fee calculation.

jr. member
Activity: 41
Merit: 1
November 04, 2015, 05:25:03 PM
#6
Or you can manually set the changeaddress when using a createrawtransaction https://en.bitcoin.it/wiki/Raw_Transactions
staff
Activity: 3458
Merit: 6793
Just writing some code
November 04, 2015, 03:21:29 PM
#5
I think you should be able to use the send many command: https://bitcoin.org/en/developer-reference#sendmany and have one of the outputs be to the change address. You would need to calculate the fee manually.
legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
November 04, 2015, 08:38:25 AM
#4

i'm' just using a plain old

coind sendtoaddress xxxxxxxxxxxxxxxxxxxx 152.3


i havent come across a rpc command at all.
it shouldnt' be that hard to get the change address from one of the inputs, it just is too hard for me Smiley
staff
Activity: 3458
Merit: 6793
Just writing some code
November 03, 2015, 09:44:19 PM
#3
How are you sending transactions? What is the command you are using?

Given that there is the option for a custom change address in the gui, you would think that there is an rpc command that lets you set the custom change, but I can't seem to find that.
legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
November 03, 2015, 08:16:37 PM
#2
here's early code from bitcoin core where it doesnt choose a random address for change.

i am unsure how the code syntax has changed since 2009 Cheesy but i imagine it's changed a bit..

https://github.com/bitcoin/bitcoin/blob/8dca7864f793072701f810e4c5ea12a6e1087085/main.cpp#L2575

Code:
               if (nValueIn > nValue)
                {
                    /// todo: for privacy, should randomize the order of outputs,
                    //        would also have to use a new key for the change.
                    // Use the same key as one of the coins
                    vector vchPubKey;
                    CTransaction& txFirst = *(*setCoins.begin());
                    foreach(const CTxOut& txout, txFirst.vout)
                        if (txout.IsMine())
                            if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))
                                break;
                    if (vchPubKey.empty())
                        return false;


                    // Fill vout[1] to ourself
                    CScript scriptPubKey;
                    scriptPubKey << vchPubKey << OP_CHECKSIG;
                    wtxNew.vout.push_back(CTxOut(nValueIn - nValue, scriptPubKey));
                }
legendary
Activity: 1204
Merit: 1000
to your stations, man the pineapples!!!
November 02, 2015, 04:02:25 AM
#1

i would like to return change to the source input address in a coind.
the point being easy tracking of coins, and easy backing up.
it's for a faucet style use.

i assume the simplest thing is to change the src code, as i cannot find any other method other than creating raw tx every time.

can anyone help with the appropriate changes ??


Code:
                    // no coin control: send change to newly generated address
                    else
                    {
                        // Note: We use a new key here to keep it from being obvious which side is the change.
                        //  The drawback is that by not reusing a previous key, the change may be lost if a
                        //  backup is restored, if the backup doesn't have the new private key for the change.
                        //  If we reused the old key, it would be possible to add code to look for and
                        //  rediscover unknown transactions that were written with keys of ours to recover
                        //  post-backup change.

                        // Reserve a new key pair from key pool
                        CPubKey vchPubKey = reservekey.GetReservedKey();

                        scriptChange.SetDestination(vchPubKey.GetID());
                    }


Jump to: