Bitcoin Forum
April 24, 2024, 08:24:48 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: return change to send address for coind  (Read 788 times)
pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
November 02, 2015, 09: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());
                    }





YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
1713990288
Hero Member
*
Offline Offline

Posts: 1713990288

View Profile Personal Message (Offline)

Ignore
1713990288
Reply with quote  #2

1713990288
Report to moderator
1713990288
Hero Member
*
Offline Offline

Posts: 1713990288

View Profile Personal Message (Offline)

Ignore
1713990288
Reply with quote  #2

1713990288
Report to moderator
"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713990288
Hero Member
*
Offline Offline

Posts: 1713990288

View Profile Personal Message (Offline)

Ignore
1713990288
Reply with quote  #2

1713990288
Report to moderator
1713990288
Hero Member
*
Offline Offline

Posts: 1713990288

View Profile Personal Message (Offline)

Ignore
1713990288
Reply with quote  #2

1713990288
Report to moderator
pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
November 04, 2015, 01:16:37 AM
 #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<unsigned char> 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));
                }



YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
achow101
Staff
Legendary
*
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
November 04, 2015, 02:44:19 AM
 #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.

pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
November 04, 2015, 01:38:25 PM
 #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



YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
achow101
Staff
Legendary
*
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
November 04, 2015, 08: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.

Mercado
Jr. Member
*
Offline Offline

Activity: 41
Merit: 1


View Profile
November 04, 2015, 10:25:03 PM
 #6

Or you can manually set the changeaddress when using a createrawtransaction https://en.bitcoin.it/wiki/Raw_Transactions
pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
November 05, 2015, 02:19:35 PM
 #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.




YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
April 15, 2016, 12:19:59 PM
 #8


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




YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
pineapples (OP)
Legendary
*
Offline Offline

Activity: 1204
Merit: 1000


to your stations, man the pineapples!!!


View Profile
April 15, 2016, 12:43:31 PM
 #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



YEEE F*#KIN HA BIG RED TEXT !!!           

(\__/)    
(='.'=)   
(")_(")   










     BUMBA
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!