Skip to content

Commit

Permalink
Revert "Merge pull request lightningnetwork#4 from LN-Zap/fix-2396"
Browse files Browse the repository at this point in the history
This reverts commit df6a916.
  • Loading branch information
bjarnemagnussen committed Jun 9, 2021
1 parent 012fc39 commit 625cbf2
Show file tree
Hide file tree
Showing 8 changed files with 3,547 additions and 3,788 deletions.
7,185 changes: 3,543 additions & 3,642 deletions lnrpc/rpc.pb.go

Large diffs are not rendered by default.

18 changes: 2 additions & 16 deletions lnrpc/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,6 @@ message Utxo {
int64 confirmations = 6;
}

message DestOutput {
// The pkscript in hex
string pk_script = 1;

// The value of the output coin in satoshis
int64 amount = 2;

// Denotes if the output is controlled by the internal wallet
bool is_our_address = 3;
}

message Transaction {
// The transaction hash
string tx_hash = 1;
Expand All @@ -579,14 +568,11 @@ message Transaction {
// Addresses that received funds for this transaction
repeated string dest_addresses = 8;

// Outputs that received funds for this transaction
repeated DestOutput dest_outputs = 9;

// The raw transaction hex.
string raw_tx_hex = 10;
string raw_tx_hex = 9;

// A label that was optionally set on transaction broadcast.
string label = 11;
string label = 10;
}
message GetTransactionsRequest {
/*
Expand Down
26 changes: 0 additions & 26 deletions lnrpc/rpc.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3616,25 +3616,6 @@
}
}
},
"lnrpcDestOutput": {
"type": "object",
"properties": {
"pk_script": {
"type": "string",
"title": "The pkscript in hex"
},
"amount": {
"type": "string",
"format": "int64",
"title": "The value of the output coin in satoshis"
},
"is_our_address": {
"type": "boolean",
"format": "boolean",
"title": "Denotes if the output is controlled by the internal wallet"
}
}
},
"lnrpcDisconnectPeerResponse": {
"type": "object"
},
Expand Down Expand Up @@ -5946,13 +5927,6 @@
},
"title": "Addresses that received funds for this transaction"
},
"dest_outputs": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcDestOutput"
},
"title": "Outputs that received funds for this transaction"
},
"raw_tx_hex": {
"type": "string",
"description": "The raw transaction hex."
Expand Down
11 changes: 0 additions & 11 deletions lnrpc/rpc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ func RPCTransactionDetails(txns []*lnwallet.TransactionDetail) *TransactionDetai
destAddresses = append(destAddresses, destAddress.EncodeAddress())
}

// Re-package destination output information.
var destOutputs []*DestOutput
for _, o := range tx.DestOutputs {
destOutputs = append(destOutputs, &DestOutput{
PkScript: hex.EncodeToString(o.PkScript),
Amount: int64(o.Value),
IsOurAddress: o.IsOurAddress,
})
}

// We also get unconfirmed transactions, so BlockHash can be
// nil.
blockHash := ""
Expand All @@ -47,7 +37,6 @@ func RPCTransactionDetails(txns []*lnwallet.TransactionDetail) *TransactionDetai
TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees,
DestAddresses: destAddresses,
DestOutputs: destOutputs,
RawTxHex: hex.EncodeToString(tx.RawTx),
Label: tx.Label,
}
Expand Down
26 changes: 0 additions & 26 deletions lnrpc/walletrpc/walletkit.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -653,25 +653,6 @@
"description": "- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)\n- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)",
"title": "`AddressType` has to be one of:"
},
"lnrpcDestOutput": {
"type": "object",
"properties": {
"pk_script": {
"type": "string",
"title": "The pkscript in hex"
},
"amount": {
"type": "string",
"format": "int64",
"title": "The value of the output coin in satoshis"
},
"is_our_address": {
"type": "boolean",
"format": "boolean",
"title": "Denotes if the output is controlled by the internal wallet"
}
}
},
"lnrpcOutPoint": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -734,13 +715,6 @@
},
"title": "Addresses that received funds for this transaction"
},
"dest_outputs": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcDestOutput"
},
"title": "Outputs that received funds for this transaction"
},
"raw_tx_hex": {
"type": "string",
"description": "The raw transaction hex."
Expand Down
38 changes: 2 additions & 36 deletions lnwallet/btcwallet/btcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,19 +923,8 @@ func minedTransactionsToDetails(
return nil, err
}

// isOurAddress is a map containing the output indices
// controlled by the wallet.
// Note: We make use of the information in `MyOutputs` provided
// by the `wallet.TransactionSummary` structure that holds
// information only if the output is controlled by the wallet.
isOurAddress := make(map[int]bool, len(tx.MyOutputs))
for _, o := range tx.MyOutputs {
isOurAddress[int(o.Index)] = true
}

var destAddresses []btcutil.Address
var destOutputs []lnwallet.DestOutput
for i, txOut := range wireTx.TxOut {
for _, txOut := range wireTx.TxOut {
_, outAddresses, _, err := txscript.ExtractPkScriptAddrs(
txOut.PkScript, chainParams,
)
Expand All @@ -946,11 +935,6 @@ func minedTransactionsToDetails(
}

destAddresses = append(destAddresses, outAddresses...)
destOutputs = append(destOutputs, lnwallet.DestOutput{
PkScript: txOut.PkScript,
Value: btcutil.Amount(txOut.Value),
IsOurAddress: isOurAddress[i],
})
}

txDetail := &lnwallet.TransactionDetail{
Expand All @@ -961,7 +945,6 @@ func minedTransactionsToDetails(
Timestamp: block.Timestamp,
TotalFees: int64(tx.Fee),
DestAddresses: destAddresses,
DestOutputs: destOutputs,
RawTx: tx.Transaction,
Label: tx.Label,
}
Expand Down Expand Up @@ -992,19 +975,8 @@ func unminedTransactionsToDetail(
return nil, err
}

// isOurAddress is a map containing the output indices controlled by
// the wallet.
// Note: We make use of the information in `MyOutputs` provided
// by the `wallet.TransactionSummary` structure that holds information
// only if the output is controlled by the wallet.
isOurAddress := make(map[int]bool, len(summary.MyOutputs))
for _, o := range summary.MyOutputs {
isOurAddress[int(o.Index)] = true
}

var destAddresses []btcutil.Address
var destOutputs []lnwallet.DestOutput
for i, txOut := range wireTx.TxOut {
for _, txOut := range wireTx.TxOut {
_, outAddresses, _, err :=
txscript.ExtractPkScriptAddrs(txOut.PkScript, chainParams)
if err != nil {
Expand All @@ -1014,19 +986,13 @@ func unminedTransactionsToDetail(
}

destAddresses = append(destAddresses, outAddresses...)
destOutputs = append(destOutputs, lnwallet.DestOutput{
PkScript: txOut.PkScript,
Value: btcutil.Amount(txOut.Value),
IsOurAddress: isOurAddress[i],
})
}

txDetail := &lnwallet.TransactionDetail{
Hash: *summary.Hash,
TotalFees: int64(summary.Fee),
Timestamp: summary.Timestamp,
DestAddresses: destAddresses,
DestOutputs: destOutputs,
RawTx: summary.Transaction,
Label: summary.Label,
}
Expand Down
11 changes: 0 additions & 11 deletions lnwallet/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ type Utxo struct {
wire.OutPoint
}

// DestOutput contains additional information on a destination address.
type DestOutput struct {
PkScript []byte
Value btcutil.Amount
IsOurAddress bool
}

// TransactionDetail describes a transaction with either inputs which belong to
// the wallet, or has outputs that pay to the wallet.
type TransactionDetail struct {
Expand Down Expand Up @@ -124,10 +117,6 @@ type TransactionDetail struct {
// DestAddresses are the destinations for a transaction
DestAddresses []btcutil.Address

// DestOutputs contains output data for each destination address, such
// as the output script and amount.
DestOutputs []DestOutput

// RawTx returns the raw serialized transaction.
RawTx []byte

Expand Down
20 changes: 0 additions & 20 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5082,15 +5082,6 @@ func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
for _, destAddress := range tx.DestAddresses {
destAddresses = append(destAddresses, destAddress.EncodeAddress())
}

destOutputs := make([]*lnrpc.DestOutput, 0, len(tx.DestOutputs))
for _, destOutput := range tx.DestOutputs {
destOutputs = append(destOutputs, &lnrpc.DestOutput{
PkScript: hex.EncodeToString(destOutput.PkScript),
Amount: int64(destOutput.Value),
IsOurAddress: destOutput.IsOurAddress,
})
}
detail := &lnrpc.Transaction{
TxHash: tx.Hash.String(),
Amount: int64(tx.Value),
Expand All @@ -5100,7 +5091,6 @@ func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees,
DestAddresses: destAddresses,
DestOutputs: destOutputs,
RawTxHex: hex.EncodeToString(tx.RawTx),
}
if err := updateStream.Send(detail); err != nil {
Expand All @@ -5112,22 +5102,12 @@ func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
for _, destAddress := range tx.DestAddresses {
destAddresses = append(destAddresses, destAddress.EncodeAddress())
}

destOutputs := make([]*lnrpc.DestOutput, 0, len(tx.DestOutputs))
for _, destOutput := range tx.DestOutputs {
destOutputs = append(destOutputs, &lnrpc.DestOutput{
PkScript: hex.EncodeToString(destOutput.PkScript),
Amount: int64(destOutput.Value),
IsOurAddress: destOutput.IsOurAddress,
})
}
detail := &lnrpc.Transaction{
TxHash: tx.Hash.String(),
Amount: int64(tx.Value),
TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees,
DestAddresses: destAddresses,
DestOutputs: destOutputs,
RawTxHex: hex.EncodeToString(tx.RawTx),
}
if err := updateStream.Send(detail); err != nil {
Expand Down

0 comments on commit 625cbf2

Please sign in to comment.