Native SegWit Addresses via BitGo’s API

Murch
Official BitGo Blog
3 min readMar 27, 2019

--

As of today’s release, it is possible to generate Native SegWit addresses from the BitGo V2 API to spend and receive funds on the Bitcoin network. Native SegWit is an improved, more weight-efficient address format than Wrapped SegWit. This follows previous support for sending to any Bech32 address.

Native SegWit addresses are especially interesting for users with a high transaction count or those that are frequently sending and receiving small amounts. It’s possible to immediately save costs by sending all change outputs to Native SegWit addresses. Additional savings can be achieved over time as adoption increases by providing the option to deposit to Native SegWit addresses. As this will chiefly benefit API users, we will not be offering Native SegWit address generation in the web UI at this time.

Native SegWit inputs have a weight of 105 bytes, down from 140 bytes for Wrapped SegWit inputs and 297 bytes for non-SegWit Pay-to-Script-Hash (P2SH). That means Native SegWit inputs will be 25% cheaper than Wrapped SegWit inputs and 65% cheaper than non-SegWit inputs. In fact that makes our Native SegWit multi-signature inputs cheaper than single-signature Pay-to-Public-Key-Hash inputs. However, Native SegWit outputs are slightly larger with 43 bytes, nominally increasing the output size from the 32 bytes of P2SH outputs.

Unfortunately, not all Bitcoin wallet software can send to Native SegWit (Bech32) addresses. Hence, BitGo wallets will continue to generate Wrapped SegWit addresses by default. If desired, users can choose Native SegWit when creating a new address by specifying the derivation chain code 20. The type of change address can be specified by setting addressType. We recommend updating to the latest BitGo SDK, but anything since BitGoJS 4.34.0 should be able to generate addresses and sign Native SegWit inputs.

SegWit address overview

Wrapped SegWit addresses lock funds to a redeem script hash like any other P2SH address. When funds get spent, the owner reveals the redeem script which in turn includes a witness program and provides a witness that satisfies both. This indirection both causes additional data to be written to the blockchain, but also makes Wrapped SegWit addresses backwards compatible. Wrapped SegWit addresses start with a “2” on Testnet and a “3” on Mainnet. They are generated with the derivation chain codes 10 and 11.

Native SegWit addresses lock funds to the hash of a witness program directly. When the owner spends the funds, they only need to provide the witness program and the witness that satisfies it. Native SegWit is more blockweight efficient, which makes it cheaper to spend from Native SegWit addresses. However, without the P2SH-wrapper only SegWit-compatible wallets can send to Native SegWit addresses. Native SegWit addresses start with a “tb1” on Testnet and a “bc1” on Mainnet. They are generated with the derivation chain codes 20 and 21.

Have questions? Please contact support@bitgo.com.

--

--