mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
lnwallet: add function to locate script index to script_utils.go
This commit is contained in:
parent
baf3b70e31
commit
d3fe04ab9b
1 changed files with 16 additions and 0 deletions
|
@ -83,3 +83,19 @@ func spendMultiSig(redeemScript, sigA, sigB []byte) ([]byte, error) {
|
||||||
// that's all, get bytes
|
// that's all, get bytes
|
||||||
return bldr.Script()
|
return bldr.Script()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// findScriptOutputIndex...
|
||||||
|
// only finds first matchin, assumes unique pkScripts
|
||||||
|
func findScriptOutputIndex(tx *wire.MsgTx, script []byte) (bool, uint32) {
|
||||||
|
found := false
|
||||||
|
index := uint32(0)
|
||||||
|
for i, txOut := range tx.TxOut {
|
||||||
|
if bytes.Equal(txOut.PkScript, script) {
|
||||||
|
found = true
|
||||||
|
index = uint32(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return found, index
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue