@@ -404,22 +404,13 @@ func (t *TapAddressBook) QueryAddrs(ctx context.Context,
404404 }
405405 }
406406
407- rawScriptKey , err := btcec . ParsePubKey (
408- addr .RawScriptKey ,
407+ scriptKey , err := parseScriptKey (
408+ addr .InternalKey , addr . ScriptKey ,
409409 )
410410 if err != nil {
411411 return fmt .Errorf ("unable to decode " +
412412 "script key: %w" , err )
413413 }
414- rawScriptKeyDesc := keychain.KeyDescriptor {
415- KeyLocator : keychain.KeyLocator {
416- Family : keychain .KeyFamily (
417- addr .ScriptKeyFamily ,
418- ),
419- Index : uint32 (addr .ScriptKeyIndex ),
420- },
421- PubKey : rawScriptKey ,
422- }
423414
424415 internalKey , err := btcec .ParsePubKey (addr .RawTaprootKey )
425416 if err != nil {
@@ -436,11 +427,6 @@ func (t *TapAddressBook) QueryAddrs(ctx context.Context,
436427 PubKey : internalKey ,
437428 }
438429
439- scriptKey , err := btcec .ParsePubKey (addr .TweakedScriptKey )
440- if err != nil {
441- return err
442- }
443-
444430 taprootOutputKey , err := schnorr .ParsePubKey (
445431 addr .TaprootOutputKey ,
446432 )
@@ -467,8 +453,8 @@ func (t *TapAddressBook) QueryAddrs(ctx context.Context,
467453
468454 tapAddr , err := address .New (
469455 address .Version (addr .Version ), assetGenesis ,
470- groupKey , groupWitness ,
471- * scriptKey , * internalKey , uint64 (addr .Amount ),
456+ groupKey , groupWitness , * scriptKey . PubKey ,
457+ * internalKey , uint64 (addr .Amount ),
472458 tapscriptSibling , t .params , * proofCourierAddr ,
473459 address .WithAssetVersion (
474460 asset .Version (addr .AssetVersion ),
@@ -478,16 +464,9 @@ func (t *TapAddressBook) QueryAddrs(ctx context.Context,
478464 return fmt .Errorf ("unable to make addr: %w" , err )
479465 }
480466
481- declaredKnown := extractBool (
482- addr .ScriptKeyDeclaredKnown ,
483- )
484467 addrs = append (addrs , address.AddrWithKeyInfo {
485- Tap : tapAddr ,
486- ScriptKeyTweak : asset.TweakedScriptKey {
487- RawKey : rawScriptKeyDesc ,
488- Tweak : addr .ScriptKeyTweak ,
489- DeclaredKnown : declaredKnown ,
490- },
468+ Tap : tapAddr ,
469+ ScriptKeyTweak : * scriptKey .TweakedScriptKey ,
491470 InternalKeyDesc : internalKeyDesc ,
492471 TaprootOutputKey : * taprootOutputKey ,
493472 CreationTime : addr .CreationTime .UTC (),
@@ -571,21 +550,7 @@ func fetchAddr(ctx context.Context, db AddrBook, params *address.ChainParams,
571550 }
572551 }
573552
574- rawScriptKey , err := btcec .ParsePubKey (dbAddr .RawScriptKey )
575- if err != nil {
576- return nil , fmt .Errorf ("unable to decode script key: %w" , err )
577- }
578- scriptKeyDesc := keychain.KeyDescriptor {
579- KeyLocator : keychain.KeyLocator {
580- Family : keychain .KeyFamily (
581- dbAddr .ScriptKeyFamily ,
582- ),
583- Index : uint32 (dbAddr .ScriptKeyIndex ),
584- },
585- PubKey : rawScriptKey ,
586- }
587-
588- scriptKey , err := btcec .ParsePubKey (dbAddr .TweakedScriptKey )
553+ scriptKey , err := parseScriptKey (dbAddr .InternalKey , dbAddr .ScriptKey )
589554 if err != nil {
590555 return nil , fmt .Errorf ("unable to decode script key: %w" , err )
591556 }
@@ -622,23 +587,18 @@ func fetchAddr(ctx context.Context, db AddrBook, params *address.ChainParams,
622587
623588 tapAddr , err := address .New (
624589 address .Version (dbAddr .Version ), genesis , groupKey ,
625- groupWitness , * scriptKey , * internalKey , uint64 (dbAddr .Amount ),
626- tapscriptSibling , params , * proofCourierAddr ,
590+ groupWitness , * scriptKey .PubKey , * internalKey ,
591+ uint64 (dbAddr .Amount ), tapscriptSibling , params ,
592+ * proofCourierAddr ,
627593 address .WithAssetVersion (asset .Version (dbAddr .AssetVersion )),
628594 )
629595 if err != nil {
630596 return nil , fmt .Errorf ("unable to make addr: %w" , err )
631597 }
632598
633599 return & address.AddrWithKeyInfo {
634- Tap : tapAddr ,
635- ScriptKeyTweak : asset.TweakedScriptKey {
636- RawKey : scriptKeyDesc ,
637- Tweak : dbAddr .ScriptKeyTweak ,
638- DeclaredKnown : extractBool (
639- dbAddr .ScriptKeyDeclaredKnown ,
640- ),
641- },
600+ Tap : tapAddr ,
601+ ScriptKeyTweak : * scriptKey .TweakedScriptKey ,
642602 InternalKeyDesc : internalKeyDesc ,
643603 TaprootOutputKey : * taprootOutputKey ,
644604 CreationTime : dbAddr .CreationTime .UTC (),
0 commit comments