diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index 1003570..98cacda 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -838,7 +838,7 @@ func lookupKeyScope(kind *string) (*waddrmgr.KeyScope, error) { case "legacy": return &waddrmgr.KeyScopeBIP0044, nil case "p2sh-segwit": - return &waddrmgr.KeyScopeBIP0049Plus, nil + return &waddrmgr.KeyScopeBIP0049, nil case "bech32": return &waddrmgr.KeyScopeBIP0084, nil } diff --git a/waddrmgr/manager.go b/waddrmgr/manager.go index a7c7e47..3800d9b 100644 --- a/waddrmgr/manager.go +++ b/waddrmgr/manager.go @@ -175,9 +175,7 @@ type accountInfo struct { lastInternalAddr ManagedAddress // addrSchema serves as a way for an account to override its - // corresponding address schema with a custom one. For example, this - // could be used to import accounts that use the traditional BIP-0049 - // derivation scheme into our KeyScopeBIP-0049Plus manager. + // corresponding address schema with a custom one. addrSchema *ScopeAddrSchema // masterKeyFingerprint represents the fingerprint of the root key diff --git a/waddrmgr/scoped_manager.go b/waddrmgr/scoped_manager.go index a2f37fe..7ec1e3f 100644 --- a/waddrmgr/scoped_manager.go +++ b/waddrmgr/scoped_manager.go @@ -142,10 +142,9 @@ type ScopeAddrSchema struct { } var ( - // KeyScopeBIP0049Plus is the key scope of our modified BIP0049 - // derivation. We say this is BIP0049 "plus", as we'll actually use - // p2wkh change all change addresses. - KeyScopeBIP0049Plus = KeyScope{ + // KeyScopeBIP0049 is the key scope for BIP0084 derivation. BIP0049 + // will be used to derive all nested p2wkh addresses. + KeyScopeBIP0049 = KeyScope{ Purpose: 49, Coin: 140, } @@ -168,7 +167,7 @@ var ( // DefaultKeyScopes is the set of default key scopes that will be // created by the root manager upon initial creation. DefaultKeyScopes = []KeyScope{ - KeyScopeBIP0049Plus, + KeyScopeBIP0049, KeyScopeBIP0084, KeyScopeBIP0044, } @@ -177,9 +176,9 @@ var ( // address schema for each scope type. This will be consulted during // the initial creation of the root key manager. ScopeAddrMap = map[KeyScope]ScopeAddrSchema{ - KeyScopeBIP0049Plus: { + KeyScopeBIP0049: { ExternalAddrType: NestedWitnessPubKey, - InternalAddrType: WitnessPubKey, + InternalAddrType: NestedWitnessPubKey, }, KeyScopeBIP0084: { ExternalAddrType: WitnessPubKey, @@ -192,9 +191,7 @@ var ( } // KeyScopeBIP0049AddrSchema is the address schema for the traditional - // BIP-0049 derivation scheme. This exists in order to support importing - // accounts from other wallets that don't use our modified BIP-0049 - // derivation scheme (internal addresses are P2WKH instead of NP2WKH). + // BIP-0049 derivation scheme. KeyScopeBIP0049AddrSchema = ScopeAddrSchema{ ExternalAddrType: NestedWitnessPubKey, InternalAddrType: NestedWitnessPubKey, @@ -2425,7 +2422,7 @@ func (s *ScopedKeyManager) cloneKeyWithVersion(key *hdkeychain.ExtendedKey) ( switch s.scope { case KeyScopeBIP0044: version = HDVersionMainNetBIP0044 - case KeyScopeBIP0049Plus: + case KeyScopeBIP0049: version = HDVersionMainNetBIP0049 case KeyScopeBIP0084: version = HDVersionMainNetBIP0084 @@ -2439,7 +2436,7 @@ func (s *ScopedKeyManager) cloneKeyWithVersion(key *hdkeychain.ExtendedKey) ( switch s.scope { case KeyScopeBIP0044: version = HDVersionTestNetBIP0044 - case KeyScopeBIP0049Plus: + case KeyScopeBIP0049: version = HDVersionTestNetBIP0049 case KeyScopeBIP0084: version = HDVersionTestNetBIP0084 @@ -2454,7 +2451,7 @@ func (s *ScopedKeyManager) cloneKeyWithVersion(key *hdkeychain.ExtendedKey) ( // We use the mainnet versions for simnet keys when the keys // belong to a key scope which simnet doesn't have a defined // version for. - case KeyScopeBIP0049Plus: + case KeyScopeBIP0049: version = HDVersionMainNetBIP0049 case KeyScopeBIP0084: version = HDVersionMainNetBIP0084 diff --git a/wallet/createtx_test.go b/wallet/createtx_test.go index de2d57f..5d3b4f8 100644 --- a/wallet/createtx_test.go +++ b/wallet/createtx_test.go @@ -38,7 +38,7 @@ func TestTxToOutputsDryRun(t *testing.T) { defer cleanup() // Create an address we can use to send some coins to. - keyScope := waddrmgr.KeyScopeBIP0049Plus + keyScope := waddrmgr.KeyScopeBIP0049 addr, err := w.CurrentAddress(0, keyScope) if err != nil { t.Fatalf("unable to get current address: %v", addr) @@ -230,7 +230,7 @@ func TestTxToOutputsRandom(t *testing.T) { defer cleanup() // Create an address we can use to send some coins to. - keyScope := waddrmgr.KeyScopeBIP0049Plus + keyScope := waddrmgr.KeyScopeBIP0049 addr, err := w.CurrentAddress(0, keyScope) if err != nil { t.Fatalf("unable to get current address: %v", addr) diff --git a/wallet/import.go b/wallet/import.go index 5546d52..e700640 100644 --- a/wallet/import.go +++ b/wallet/import.go @@ -49,7 +49,7 @@ func keyScopeFromPubKey(pubKey *hdkeychain.ExtendedKey, switch *addrType { case waddrmgr.NestedWitnessPubKey: - return waddrmgr.KeyScopeBIP0049Plus, + return waddrmgr.KeyScopeBIP0049, &waddrmgr.KeyScopeBIP0049AddrSchema, nil case waddrmgr.WitnessPubKey: @@ -74,11 +74,11 @@ func keyScopeFromPubKey(pubKey *hdkeychain.ExtendedKey, switch *addrType { case waddrmgr.NestedWitnessPubKey: - return waddrmgr.KeyScopeBIP0049Plus, + return waddrmgr.KeyScopeBIP0049, &waddrmgr.KeyScopeBIP0049AddrSchema, nil case waddrmgr.WitnessPubKey: - return waddrmgr.KeyScopeBIP0049Plus, nil, nil + return waddrmgr.KeyScopeBIP0049, nil, nil default: return waddrmgr.KeyScope{}, nil, @@ -370,7 +370,7 @@ func (w *Wallet) ImportPublicKey(pubKey *btcec.PublicKey, var keyScope waddrmgr.KeyScope switch addrType { case waddrmgr.NestedWitnessPubKey: - keyScope = waddrmgr.KeyScopeBIP0049Plus + keyScope = waddrmgr.KeyScopeBIP0049 case waddrmgr.WitnessPubKey: keyScope = waddrmgr.KeyScopeBIP0084 default: diff --git a/wallet/import_test.go b/wallet/import_test.go index 294325d..28a4551 100644 --- a/wallet/import_test.go +++ b/wallet/import_test.go @@ -79,7 +79,7 @@ var ( "Y3BZdhdtUcw", accountIndex: 0, addrType: waddrmgr.NestedWitnessPubKey, - expectedScope: waddrmgr.KeyScopeBIP0049Plus, + expectedScope: waddrmgr.KeyScopeBIP0049, expectedAddr: "2N5YTxG9XtGXx1YyhZb7N2pwEjoZLLMHGKj", expectedChangeAddr: "2N7wpz5Gy2zEJTvq2MAuU6BCTEBLXNQ8dUw", }, { @@ -99,7 +99,7 @@ var ( "FD2KeY6G9", accountIndex: 9, addrType: waddrmgr.NestedWitnessPubKey, - expectedScope: waddrmgr.KeyScopeBIP0049Plus, + expectedScope: waddrmgr.KeyScopeBIP0049, expectedAddr: "2NBCJ9WzGXZqpLpXGq3Hacybj3c4eHRcqgh", expectedChangeAddr: "2N3bankFu6F3ZNU41iVJQqyS9MXqp9dvn1M", }, { @@ -109,7 +109,7 @@ var ( "FD2KeY6G9", accountIndex: 9, addrType: waddrmgr.WitnessPubKey, - expectedScope: waddrmgr.KeyScopeBIP0049Plus, + expectedScope: waddrmgr.KeyScopeBIP0049, expectedAddr: "2NBCJ9WzGXZqpLpXGq3Hacybj3c4eHRcqgh", expectedChangeAddr: "tb1qeqn05w2hfq6axpdprhs4y7x65gxkkvfvyxqk4u", }, { diff --git a/wallet/psbt_test.go b/wallet/psbt_test.go index d52ceea..bd1a6d6 100644 --- a/wallet/psbt_test.go +++ b/wallet/psbt_test.go @@ -43,7 +43,7 @@ func TestFundPsbt(t *testing.T) { } // Also create a nested P2WKH address we can use to send some coins to. - addr, err = w.CurrentAddress(0, waddrmgr.KeyScopeBIP0049Plus) + addr, err = w.CurrentAddress(0, waddrmgr.KeyScopeBIP0049) if err != nil { t.Fatalf("unable to get current address: %v", addr) } @@ -353,7 +353,7 @@ func TestFinalizePsbt(t *testing.T) { } // Also create a nested P2WKH address we can send coins to. - addr, err = w.CurrentAddress(0, waddrmgr.KeyScopeBIP0049Plus) + addr, err = w.CurrentAddress(0, waddrmgr.KeyScopeBIP0049) if err != nil { t.Fatalf("unable to get current address: %v", addr) } diff --git a/wallet/signer_test.go b/wallet/signer_test.go index 1fd4f9a..3d95624 100644 --- a/wallet/signer_test.go +++ b/wallet/signer_test.go @@ -26,7 +26,7 @@ func TestComputeInputScript(t *testing.T) { expectedScriptLen: 0, }, { name: "BIP049 nested P2WKH", - scope: waddrmgr.KeyScopeBIP0049Plus, + scope: waddrmgr.KeyScopeBIP0049, expectedScriptLen: 23, }}