From d3fe04ab9b50fcb26b96890b554c33cba3817191 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 20 Dec 2015 21:47:29 -0600 Subject: [PATCH] lnwallet: add function to locate script index to script_utils.go --- lnwallet/script_utils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lnwallet/script_utils.go b/lnwallet/script_utils.go index 6de56906..a3d0caf8 100644 --- a/lnwallet/script_utils.go +++ b/lnwallet/script_utils.go @@ -83,3 +83,19 @@ func spendMultiSig(redeemScript, sigA, sigB []byte) ([]byte, error) { // that's all, get bytes 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 +}