Pages:
Author

Topic: P2SH-P2WPKH (Segwit) change addresses in Bitcoin Core - how? - page 2. (Read 3765 times)

legendary
Activity: 954
Merit: 1003
+1, need a simple solution to migrate to segwit addresses.
sr. member
Activity: 745
Merit: 471
Admin at YOLOdice.com - fast, fair, play/invest.
Thanks for the link. But actually this discussion did not reach any conclusion. My use case is simple: I am using Bitcoin Core as a wallet and I want to benefit from Segwit addresses. Since Bitcoin Core is THE Bitcoin wallet, it should somehow help its users migrate to Segwit setups.

This problem will become more common in the next few days when people realize it's not THAT easy to use Segwit.

I know the initial rationale for not enabling Segwit addresses by default is to protect the privacy, but come on, it should not be that difficult to use Bitcoin Core as a 100% Segwit wallet.
sr. member
Activity: 745
Merit: 471
Admin at YOLOdice.com - fast, fair, play/invest.
Hi,

I am running a service that accepts user deposits and sends withdrawals. I am using Bitcoin Core for the wallet.

I'd like to go full-Segwit with my service, but here's the problem: bitcoind wallet does not generate P2SH-P2WPKH (Segwit) change addresses by default. So even if I generate P2SH-P2WPKH addresses to accept deposits from my users via addwitnessaddress, whenever I send coins, the change is going to a P2PKH address.

I could manually create a P2SH-P2WPKH change address by (in pseudocode):

Code:
tx = createrawtransaction([], amounts)
chaddr = getrawchangeaddress()
chaddr = addwitnessaddress(chaddr) # this creates a P2SH-P2WPKH address from the P2PKH change address
# now fund the transaction
tx = fundrawtransaction(tx, changeAddress: chaddr)['hex']
tx = signrawtransaction(tx)['hex']
sendrawtransaction(tx)

No the thing is that addwitnessaddress(chaddr) breaks things a little since the resulting address is added to account addresses, and is NOT marked as a change address. Therefore it is used as a regular account address and generates send/receive transactions. It looks like it does not break anything except creating additional transactions returned by listtransactions and inaccurate "amount" fields.

So, a solution I'd really love to see is:

1. make the wallet generate segwit change addresses by itself so that we can just use sendtoaddress and other RPC calls without workarounds (maybe an option in config?),
2. somehow make the address resulting from addwitnessaddress(chaddr) as a change address,
3. or allow getrawchangeaddress to generate P2SH-P2WPH address in the first place.

Obviously (1) would be much better, but at this point I am looking for any solution that would "just work" and not break my workflow.

Cheers and thanks,
Ethan
Pages:
Jump to: