From 3a179a0eeea7e62b1308279c88b708c53f617f49 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Tue, 5 Jul 2022 20:11:29 -0700 Subject: [PATCH] [lbry] rpc: un-embedded attributes in getaddressinfo result lbcwallet failed to re-generate RPC help message. The help message generator doesn't handle embedded fields properly. --- btcjson/walletsvrresults.go | 21 ++++++++++++++++++++- btcjson/walletsvrresults_test.go | 6 ++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/btcjson/walletsvrresults.go b/btcjson/walletsvrresults.go index 2b7354e7..4939454d 100644 --- a/btcjson/walletsvrresults.go +++ b/btcjson/walletsvrresults.go @@ -53,7 +53,26 @@ type embeddedAddressInfo struct { // 3. Information about the embedded address in case of P2SH or P2WSH. // Same structure as (1). type GetAddressInfoResult struct { - embeddedAddressInfo + // The following fields are identical to embeddedAddressInfo. + // However, the utility to generate RPC help message can't handle + // embedded field properly. So, spell out the attributes individually. + Address string `json:"address"` + ScriptPubKey string `json:"scriptPubKey"` + Descriptor *string `json:"desc,omitempty"` + IsScript bool `json:"isscript"` + IsChange bool `json:"ischange"` + IsWitness bool `json:"iswitness"` + WitnessVersion int `json:"witness_version,omitempty"` + WitnessProgram *string `json:"witness_program,omitempty"` + ScriptType *txscript.ScriptClass `json:"script,omitempty"` + Hex *string `json:"hex,omitempty"` + PubKeys *[]string `json:"pubkeys,omitempty"` + SignaturesRequired *int `json:"sigsrequired,omitempty"` + PubKey *string `json:"pubkey,omitempty"` + IsCompressed *bool `json:"iscompressed,omitempty"` + HDMasterFingerprint *string `json:"hdmasterfingerprint,omitempty"` + Labels []string `json:"labels"` + IsMine bool `json:"ismine"` IsWatchOnly bool `json:"iswatchonly"` Timestamp *int `json:"timestamp,omitempty"` diff --git a/btcjson/walletsvrresults_test.go b/btcjson/walletsvrresults_test.go index 510c367c..0db2eafc 100644 --- a/btcjson/walletsvrresults_test.go +++ b/btcjson/walletsvrresults_test.go @@ -37,10 +37,8 @@ func TestGetAddressInfoResult(t *testing.T) { name: "GetAddressInfoResult - ScriptType", result: `{"script":"nonstandard","address":"1abc"}`, want: GetAddressInfoResult{ - embeddedAddressInfo: embeddedAddressInfo{ - Address: "1abc", - ScriptType: nonStandard, - }, + Address: "1abc", + ScriptType: nonStandard, }, }, {