Bitcoin Forum
July 24, 2024, 03:26:16 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Making it easier to handle change/leftovers  (Read 989 times)
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 09:44:55 AM
Last edit: February 01, 2016, 12:24:32 PM by codedelux
 #1

I think it could be "more safe" and friendly for new devs if you could call a single function with fromAddress, toAddres and addressForWhatsLeft from console in a single command.

My example:

sendFunction(arrayFrom, arrayTo, addressForWhatsLeft)

When using the testnet I lost my coins a couple of times trying to figure out how to create transactions and handle the spare change.


Thanks for your time.

*Edited better explanation.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 09:49:48 AM
 #2

My example:

sendFunction(arrayFrom, arrayTo, addressForWhatsLeft)

As the "address for what's left" (after fees of course) is just another "to" you only need this:

Code:
sendFunction(arrayFrom, arrayTo

which funnily enough is what is provided.

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 09:55:26 AM
 #3

My example:

sendFunction(arrayFrom, arrayTo, addressForWhatsLeft)

As the "address for what's left" (after fees of course) is just another "to" you only need this:

Code:
sendFunction(arrayFrom, arrayTo

which funnily enough is what is provided.


But don't you need to calc the exact amount for the last address?
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 09:57:11 AM
 #4

But don't you need to calc the exact amount for the last address?

Are you referring to fee calculation?

(perhaps I am not quite understanding the issue you are describing)

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 10:06:44 AM
 #5

But don't you need to calc the exact amount for the last address?

Are you referring to fee calculation?

(perhaps I am not quite understanding the issue you are describing)

Yes, the fee calc is one of the things I find hard to calc when getting into the console api.

"These addresses have 10 btc. Send 1 here and here and here. Calc the fee's and send the rest here". Return true of possible, else false.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 10:12:04 AM
 #6

If you just use the "sendtoaddress" then it will look after the change automatically for you (as well as choosing the UTXOs automatically) - I don't think it can get much simpler than that.


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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 10:31:01 AM
 #7

If you just use the "sendtoaddress" then it will look after the change automatically for you (as well as choosing the UTXOs automatically) - I don't think it can get much simpler than that.



How would you suggest handling 'source coins'/change manually if you use sendtoaddress without using 'accounts'?

I followed this https://bitcoin.org/en/developer-examples#transaction-tutorial when I started out. I found it to be quite complicated to handle the source and the change this way. Googling it shows that lots of people have trouble with the select source and change handling.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 10:33:17 AM
 #8

I followed this https://bitcoin.org/en/developer-examples#transaction-tutorial when I started out. I found it to be quite complicated to handle the source and the change this way. Googling it shows that lots of people have trouble with the select source and change handling.

How is this complicated?

Code:
> bitcoin-cli -regtest sendtoaddress $ADDRESS 10.00

(I fail to see how it could really be any simpler)

If you don't want to deal with the UTXOs, fee calculation and change address then you just use "sendtoaddress" and it does all of that for you.

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 10:44:55 AM
 #9

But why not meet in the middle? Why only the most simplistic and the most complex? Why not have a function that allows source/to/change handling directly and let core guard it from stupid mistakes? It's not a new function, only a helper.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 11:04:22 AM
 #10

But why not meet in the middle? Why only the most simplistic and the most complex? Why not have a function that allows source/to/change handling directly and let core guard it from stupid mistakes? It's not a new function, only a helper.

I do believe that they added something to prevent you from sending a ridiculously large fee now (which would have helped me out a long time back when I first started playing with raw transactions).

Perhaps you should look into some of the other available wallets (maybe they'll have closer to the functionality you are wanting)?

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 11:15:33 AM
 #11

I used php to achive what I wanted, but without the https://bitcoin.org/en/developer-examples it would have been too hard for me. After talking to a friend about it who got stuck in sendmany, only using the commanline, I thought I would bring it up here.
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1086


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 01, 2016, 11:20:18 AM
 #12

I guess the problem is that I'm not really getting the actual "use case" that you are trying to handle (so it's not clear to me exactly why the standard send commands are not suitable).

Certainly I would agree that "raw transactions" are only for advanced users.

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

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
codedelux (OP)
Full Member
***
Offline Offline

Activity: 125
Merit: 100


c++


View Profile
February 01, 2016, 11:24:11 AM
 #13

I wanted to split coins sent to an address between players and the rest would go to the bank or a random random player.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
February 01, 2016, 11:40:14 AM
 #14

If you just use the "sendtoaddress" then it will look after the change automatically for you (as well as choosing the UTXOs automatically) - I don't think it can get much simpler than that.



Thats exactly what i just wanted to write.
I think its simple enough. You just have to look into it before starting sending TX's

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!