Post
Topic
Board Bitcoin Technical Support
Re: SegWit change address becomes legacy???
by
columbo
on 15/11/2017, 16:39:26 UTC
What do you think about this solution?
In my case, after a transaction from segwit addresses I ended up with my entire balance on one legacy address.
So, what if before each spending, I check the balance of the wallet (in my case only one address) and calculate the change amount before payment is made.
So, for example: if my balance is 0.55 and I need to send 0.25 to somebody, the change will be 0.30 (minus fee).
Now, I can easily include in sendmany a new (or existing) segwit address I generate and make sure the fee is deducted only from the new segwit address. This way, I will end up with 0.30 minus the sending fee in a new segwit address. And next time, when I send out funds, I always do this, so I will always end up with my balance on one segwit address.

Is there anything wrong with my assumption?

How do you specify what address in sendmany will be used as a miner's fee?

Code:
sendmany {address:amount,...} [minconf=1] [comment]

The point of sendmany was to allow several recipients (to send to different addresses at once from a single input) but I dont see where it lets you specify what address is going to be used as a fee.

I would be sure to know what im doing before doing anything of this nature.

sendmany has the option to select which receiving address will pay the fee. So, if I treat my change / segwit address as one of the recipients and specify that the fee is deducted only from this new change / segwit address than this address will receive everything back (my starting balance on original segwit account minus all payments need to be made) minus the fee.

https://chainquery.com/bitcoin-api/sendmany

Parameter #1—from account
Parameter #2—the addresses and amounts to pay
Parameter #3—minimum confirmations
Parameter #4—a comment
Parameter #5-subtractfeefromamount is missing from the bitcoin RPC GitHub Issue #6500
Result—a TXID of the sent transaction