Bitcoin Forum
June 20, 2024, 03:41:00 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Sending coins and receive "change" on special BTCAdr  (Read 138 times)
CyberOperations (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 05, 2022, 08:32:23 AM
 #1

Hello, this is my first post and I really hope this question wasn't answered already, or is too noobish.
My search did not find a related topic, but the forum tells me I might be searching too quick  Grin
So I am asking you specialists here.

I wanted to work with labels (accounts) inside my testwallet, so I can manage different people,
that got their address bound to this "label/account". I know accounts are deprecated, but did not find
another solution.

Currently I am sending coins like this:

sendfrom "label" "to-btcadr" "amount"

e.g. >> btc-cli.exe sendfrom "Person 1" BTCADRxyz 0.1

Label "Person 1" has only one BTCAddress, but the "change" from this transaction
will create a new BTCAddress. This leads to a wrong balance checking his main BTCAdr.

My question is: how could I still send from one BTCAddress (or label) to another BTCAddress
and receive the change on a specific BTCAddress (prefered my main BTCAddress for the senind person)
via cli?
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1554
Merit: 7577


Protocols over bureaucrats


View Profile
May 05, 2022, 08:47:23 AM
Merited by pooya87 (2), ABCbits (2), Hyphen(-) (1)
 #2

My question is: how could I still send from one BTCAddress (or label) to another BTCAddress
and receive the change on a specific BTCAddress (prefered my main BTCAddress for the senind person)
via cli?
Using sendmany. Example from the RPC API Reference:
bitcoin-cli sendmany "" "{\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\":0.01,\"bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3\":0.02}"

The first address is your person's address, the second is the change.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
CyberOperations (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
May 05, 2022, 09:10:33 AM
Last edit: May 05, 2022, 10:24:57 AM by CyberOperations
 #3

Thank you. I guess that is a good way to handle it.
But I still need to figure out how to set the address it lowers the balance from,
so it takes it from the right account.

Currently it seems it is picking the BTC from the entire wallet, not from
let's say label "John", who is sending 2 of his BTC to "Peter".

EDIT: seems like the "move" command might solve my problems here inside the same wallet working with accounts.
Will update once tested.

Update:
sendmany '.$fromadrlabel.' {\"'.$toadr.'\":'.$amount.'}"',

and

move "'.$fromadrlabel.'" "'.$toadrlabel.'" '.$amount.'1',

did the trick for me. Thank you for helping to understand Smiley
takuma sato
Sr. Member
****
Offline Offline

Activity: 309
Merit: 431


View Profile
May 06, 2022, 05:04:51 PM
 #4

I wouldn't pick coins from "labels", you can make mistakes, have repeated labels etc. I would always manually copypaste the addresses I want to use, or just manually click on them with CoinControl enabled where you can see them on a list in a tree form and with the labels.
Cricktor
Legendary
*
Offline Offline

Activity: 798
Merit: 1162


Crypto Swap Exchange


View Profile
May 06, 2022, 10:52:55 PM
 #5

@CyberOperations
Do you understand that Bitcoin transactions spend whole UTXO(s) and don't work account based like a bank account where you can deduce some small fraction of the total balance? (UTXO is Unspend Transaction Output, ie. a spendable output of a previous transaction).

I suggest a visit to https://learnmeabitcoin.com for basics or more.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NotATether
Legendary
*
Offline Offline

Activity: 1638
Merit: 6905


bitcoincleanup.com / bitmixlist.org


View Profile WWW
May 07, 2022, 04:29:43 AM
 #6

You can use listaddressgroupings RPC call and pass it an address, and it will list all of the change addresses associated with it. Then proceed to sweep those change addresses into your main address.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!