multi: move GetChanPointFundingTxid from lnd to lnrpc
This refactor-only change makes the GetChanPointFundingTxid helper function available from sub-systems outside of the root lnd package.
This commit is contained in:
1 parent
db76b970ac
commit
ce2796257e
11 files changed
+82
-89
No files matched your search
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"sort"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
)
|
||||
|
||||
@@ -88,3 +89,26 @@ func ExtractMinConfs(minConfs int32, spendUnconfirmed bool) (int32, error) {
|
||||
return minConfs, nil
|
||||
}
|
||||
}
|
||||
|
||||
// GetChanPointFundingTxid returns the given channel point's funding txid in
|
||||
// raw bytes.
|
||||
func GetChanPointFundingTxid(chanPoint *ChannelPoint) (*chainhash.Hash, error) {
|
||||
var txid []byte
|
||||
|
||||
// A channel point's funding txid can be get/set as a byte slice or a
|
||||
// string. In the case it is a string, decode it.
|
||||
switch chanPoint.GetFundingTxid().(type) {
|
||||
case *ChannelPoint_FundingTxidBytes:
|
||||
txid = chanPoint.GetFundingTxidBytes()
|
||||
case *ChannelPoint_FundingTxidStr:
|
||||
s := chanPoint.GetFundingTxidStr()
|
||||
h, err := chainhash.NewHashFromStr(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
txid = h[:]
|
||||
}
|
||||
|
||||
return chainhash.NewHash(txid)
|
||||
}
|
||||
Reference in new issue
Block a user