lnrpc: add previous_outpoints to listchaintxns

This commit is contained in:
priyanshiiit committed 2022-06-27 15:57:57 +05:30
1 parent 61493a5f29
commit 983d917d4a
5 files changed
+4014 -3861

No files matched your search

+3941 -3850
View File
File diff suppressed because it is too large. Load diff
+13
View File
@@ -686,7 +686,11 @@ message Transaction {
// A label that was optionally set on transaction broadcast. // A label that was optionally set on transaction broadcast.
string label = 10; string label = 10;
// PreviousOutpoints/Inputs of this transaction.
repeated PreviousOutPoint previous_outpoints = 12;
} }
message GetTransactionsRequest { message GetTransactionsRequest {
/* /*
The height from which to list transactions, inclusive. If this value is The height from which to list transactions, inclusive. If this value is
@@ -1007,6 +1011,15 @@ message OutPoint {
uint32 output_index = 3; uint32 output_index = 3;
} }
message PreviousOutPoint {
// The outpoint in format txid:n.
string outpoint = 1;
// Denotes if the outpoint is controlled by the internal wallet.
// The flag will only detect p2wkh, np2wkh and p2tr inputs as its own.
bool is_our_output = 2;
}
message LightningAddress { message LightningAddress {
// The identity pubkey of the Lightning node. // The identity pubkey of the Lightning node.
string pubkey = 1; string pubkey = 1;
+20
View File
@@ -5879,6 +5879,19 @@
} }
} }
}, },
"lnrpcPreviousOutPoint": {
"type": "object",
"properties": {
"outpoint": {
"type": "string",
"description": "The outpoint in format txid:n."
},
"is_our_output": {
"type": "boolean",
"description": "Denotes if the outpoint is controlled by the internal wallet.\nThe flag will only detect p2wkh, np2wkh and p2tr inputs as its own."
}
}
},
"lnrpcPsbtShim": { "lnrpcPsbtShim": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -6501,6 +6514,13 @@
"label": { "label": {
"type": "string", "type": "string",
"description": "A label that was optionally set on transaction broadcast." "description": "A label that was optionally set on transaction broadcast."
},
"previous_outpoints": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcPreviousOutPoint"
},
"description": "PreviousOutpoints/Inputs of this transaction."
} }
} }
}, },
+20 -11
View File
@@ -45,6 +45,14 @@ func RPCTransaction(tx *lnwallet.TransactionDetail) *Transaction {
}) })
} }
previousOutpoints := make([]*PreviousOutPoint, len(tx.PreviousOutpoints))
for idx, previousOutPoint := range tx.PreviousOutpoints {
previousOutpoints[idx] = &PreviousOutPoint{
Outpoint: previousOutPoint.OutPoint,
IsOurOutput: previousOutPoint.IsOurOutput,
}
}
// We also get unconfirmed transactions, so BlockHash can be nil. // We also get unconfirmed transactions, so BlockHash can be nil.
blockHash := "" blockHash := ""
if tx.BlockHash != nil { if tx.BlockHash != nil {
@@ -52,17 +60,18 @@ func RPCTransaction(tx *lnwallet.TransactionDetail) *Transaction {
} }
return &Transaction{ return &Transaction{
TxHash: tx.Hash.String(), TxHash: tx.Hash.String(),
Amount: int64(tx.Value), Amount: int64(tx.Value),
NumConfirmations: tx.NumConfirmations, NumConfirmations: tx.NumConfirmations,
BlockHash: blockHash, BlockHash: blockHash,
BlockHeight: tx.BlockHeight, BlockHeight: tx.BlockHeight,
TimeStamp: tx.Timestamp, TimeStamp: tx.Timestamp,
TotalFees: tx.TotalFees, TotalFees: tx.TotalFees,
DestAddresses: destAddresses, DestAddresses: destAddresses,
OutputDetails: outputDetails, OutputDetails: outputDetails,
RawTxHex: hex.EncodeToString(tx.RawTx), RawTxHex: hex.EncodeToString(tx.RawTx),
Label: tx.Label, Label: tx.Label,
PreviousOutpoints: previousOutpoints,
} }
} }
+20
View File
@@ -769,6 +769,19 @@
], ],
"default": "SCRIPT_TYPE_PUBKEY_HASH" "default": "SCRIPT_TYPE_PUBKEY_HASH"
}, },
"lnrpcPreviousOutPoint": {
"type": "object",
"properties": {
"outpoint": {
"type": "string",
"description": "The outpoint in format txid:n."
},
"is_our_output": {
"type": "boolean",
"description": "Denotes if the outpoint is controlled by the internal wallet.\nThe flag will only detect p2wkh, np2wkh and p2tr inputs as its own."
}
}
},
"lnrpcTransaction": { "lnrpcTransaction": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -826,6 +839,13 @@
"label": { "label": {
"type": "string", "type": "string",
"description": "A label that was optionally set on transaction broadcast." "description": "A label that was optionally set on transaction broadcast."
},
"previous_outpoints": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcPreviousOutPoint"
},
"description": "PreviousOutpoints/Inputs of this transaction."
} }
} }
}, },