diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 829b236a8..a8f44a71e 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -1023,7 +1023,6 @@ func minedTransactionsToDetails( isOurAddress[int(o.Index)] = true } - var destAddresses []btcutil.Address var outputDetails []lnwallet.OutputDetail for i, txOut := range wireTx.TxOut { var addresses []btcutil.Address @@ -1032,7 +1031,6 @@ func minedTransactionsToDetails( ) if err == nil { // Add supported addresses. - destAddresses = append(destAddresses, outAddresses...) addresses = outAddresses } @@ -1053,7 +1051,6 @@ func minedTransactionsToDetails( BlockHeight: block.Height, Timestamp: block.Timestamp, TotalFees: int64(tx.Fee), - DestAddresses: destAddresses, OutputDetails: outputDetails, RawTx: tx.Transaction, Label: tx.Label, @@ -1095,7 +1092,6 @@ func unminedTransactionsToDetail( isOurAddress[int(o.Index)] = true } - var destAddresses []btcutil.Address var outputDetails []lnwallet.OutputDetail for i, txOut := range wireTx.TxOut { var addresses []btcutil.Address @@ -1104,7 +1100,6 @@ func unminedTransactionsToDetail( ) if err == nil { // Add supported addresses. - destAddresses = append(destAddresses, outAddresses...) addresses = outAddresses } @@ -1122,7 +1117,6 @@ func unminedTransactionsToDetail( Hash: *summary.Hash, TotalFees: int64(summary.Fee), Timestamp: summary.Timestamp, - DestAddresses: destAddresses, OutputDetails: outputDetails, RawTx: summary.Transaction, Label: summary.Label, diff --git a/lnwallet/interface.go b/lnwallet/interface.go index 423c59ecd..5475ad62f 100644 --- a/lnwallet/interface.go +++ b/lnwallet/interface.go @@ -128,9 +128,6 @@ type TransactionDetail struct { // TotalFees is the total fee in satoshis paid by this transaction. TotalFees int64 - // DestAddresses are the destinations for a transaction - DestAddresses []btcutil.Address - // OutputDetails contains output data for each destination address, such // as the output script and amount. OutputDetails []OutputDetail diff --git a/lnwallet/test/test_interface.go b/lnwallet/test/test_interface.go index c77baeb4d..cba0eae7b 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -1140,6 +1140,7 @@ func testListTransactionDetails(miner *rpctest.Harness, // Create 5 new outputs spendable by the wallet. const numTxns = 5 const outputAmt = btcutil.SatoshiPerBitcoin + isOurAddress := make(map[string]bool) txids := make(map[chainhash.Hash]struct{}) for i := 0; i < numTxns; i++ { addr, err := alice.NewAddress( @@ -1149,6 +1150,7 @@ func testListTransactionDetails(miner *rpctest.Harness, if err != nil { t.Fatalf("unable to create new address: %v", err) } + isOurAddress[addr.EncodeAddress()] = true script, err := txscript.PayToAddrScript(addr) if err != nil { t.Fatalf("unable to create output script: %v", err) @@ -1245,20 +1247,27 @@ func testListTransactionDetails(miner *rpctest.Harness, t.Fatalf("tx (%v) not found in block (%v)", txDetail.Hash, txDetail.BlockHash) } else { - var destinationAddresses []btcutil.Address + var destinationOutputs []lnwallet.OutputDetail - for _, txOut := range txOuts { - _, addrs, _, err := + for i, txOut := range txOuts { + sc, addrs, _, err := txscript.ExtractPkScriptAddrs(txOut.PkScript, &alice.Cfg.NetParams) if err != nil { t.Fatalf("err extract script addresses: %s", err) } - destinationAddresses = append(destinationAddresses, addrs...) + destinationOutputs = append(destinationOutputs, lnwallet.OutputDetail{ + OutputType: sc, + Addresses: addrs, + PkScript: txOut.PkScript, + OutputIndex: i, + Value: btcutil.Amount(txOut.Value), + IsOurAddress: isOurAddress[addrs[0].EncodeAddress()], + }) } - if !reflect.DeepEqual(txDetail.DestAddresses, destinationAddresses) { - t.Fatalf("destination addresses mismatch, got %v expected %v", - txDetail.DestAddresses, destinationAddresses) + if !reflect.DeepEqual(txDetail.OutputDetails, destinationOutputs) { + t.Fatalf("destination outputs mismatch, got %v expected %v", + txDetail.OutputDetails, destinationOutputs) } } @@ -1330,10 +1339,12 @@ func testListTransactionDetails(miner *rpctest.Harness, // that even when we have 0 confirmation transactions, the destination // addresses are returned. var match bool - for _, addr := range txDetail.DestAddresses { - if addr.String() == minerAddr.String() { - match = true - break + for _, o := range txDetail.OutputDetails { + for _, addr := range o.Addresses { + if addr.String() == minerAddr.String() { + match = true + break + } } } if !match {