2015-12-31 09:28:14 +03:00
|
|
|
package lnwire
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/hex"
|
2016-12-22 23:17:24 +03:00
|
|
|
"net"
|
|
|
|
|
2016-05-23 23:47:23 +03:00
|
|
|
"github.com/roasbeef/btcd/btcec"
|
2017-01-06 00:56:27 +03:00
|
|
|
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
2016-05-23 23:47:23 +03:00
|
|
|
"github.com/roasbeef/btcd/txscript"
|
|
|
|
"github.com/roasbeef/btcd/wire"
|
2015-12-31 09:28:14 +03:00
|
|
|
)
|
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// Common variables and functions for the message tests
|
2015-12-31 09:28:14 +03:00
|
|
|
var (
|
2016-06-30 21:53:11 +03:00
|
|
|
revHash = [32]byte{
|
|
|
|
0xb7, 0x94, 0x38, 0x5f, 0x2d, 0x1e, 0xf7, 0xab,
|
|
|
|
0x4d, 0x92, 0x73, 0xd1, 0x90, 0x63, 0x81, 0xb4,
|
|
|
|
0x4f, 0x2f, 0x6f, 0x25, 0x88, 0xa3, 0xef, 0xb9,
|
|
|
|
0x6a, 0x49, 0x18, 0x83, 0x31, 0x98, 0x47, 0x53,
|
|
|
|
}
|
|
|
|
|
2017-02-16 15:34:44 +03:00
|
|
|
shaHash1Bytes, _ = hex.DecodeString("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
|
|
|
shaHash1, _ = chainhash.NewHash(shaHash1Bytes)
|
|
|
|
outpoint1 = wire.NewOutPoint(shaHash1, 0)
|
2016-01-05 19:19:22 +03:00
|
|
|
|
2015-12-31 09:28:14 +03:00
|
|
|
privKeyBytes, _ = hex.DecodeString("9fa1d55217f57019a3c37f49465896b15836f54cb8ef6963870a52926420a2dd")
|
|
|
|
privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes)
|
2016-01-05 19:19:22 +03:00
|
|
|
address = pubKey
|
2015-12-31 09:28:14 +03:00
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// Commitment Signature
|
2017-01-06 00:56:27 +03:00
|
|
|
tx = wire.NewMsgTx(1)
|
2015-12-31 09:28:14 +03:00
|
|
|
emptybytes = new([]byte)
|
|
|
|
sigStr, _ = txscript.RawTxInSignature(tx, 0, *emptybytes, txscript.SigHashAll, privKey)
|
|
|
|
commitSig, _ = btcec.ParseSignature(sigStr, btcec.S256())
|
|
|
|
|
|
|
|
sig1privKeyBytes, _ = hex.DecodeString("927f5827d75dd2addeb532c0fa5ac9277565f981dd6d0d037b422be5f60bdbef")
|
|
|
|
sig1privKey, _ = btcec.PrivKeyFromBytes(btcec.S256(), sig1privKeyBytes)
|
|
|
|
sigStr1, _ = txscript.RawTxInSignature(tx, 0, *emptybytes, txscript.SigHashAll, sig1privKey)
|
|
|
|
commitSig1, _ = btcec.ParseSignature(sigStr1, btcec.S256())
|
2017-02-16 15:34:44 +03:00
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// Funding TX Sig 2
|
2015-12-31 09:28:14 +03:00
|
|
|
sig2privKeyBytes, _ = hex.DecodeString("8a4ad188f6f4000495b765cfb6ffa591133a73019c45428ddd28f53bab551847")
|
|
|
|
sig2privKey, _ = btcec.PrivKeyFromBytes(btcec.S256(), sig2privKeyBytes)
|
|
|
|
sigStr2, _ = txscript.RawTxInSignature(tx, 0, *emptybytes, txscript.SigHashAll, sig2privKey)
|
|
|
|
commitSig2, _ = btcec.ParseSignature(sigStr2, btcec.S256())
|
2016-01-17 04:14:35 +03:00
|
|
|
// Slice of Funding TX Sigs
|
2015-12-31 11:25:00 +03:00
|
|
|
ptrFundingTXSigs = append(*new([]*btcec.Signature), commitSig1, commitSig2)
|
2015-12-31 09:28:14 +03:00
|
|
|
|
2016-01-17 04:14:35 +03:00
|
|
|
// TxID
|
2017-01-06 00:56:27 +03:00
|
|
|
txid = new(chainhash.Hash)
|
2016-01-17 04:14:35 +03:00
|
|
|
// Reversed when displayed
|
2015-12-31 09:28:14 +03:00
|
|
|
txidBytes, _ = hex.DecodeString("fd95c6e5c9d5bcf9cfc7231b6a438e46c518c724d0b04b75cc8fddf84a254e3a")
|
|
|
|
_ = copy(txid[:], txidBytes)
|
2016-12-07 18:46:22 +03:00
|
|
|
|
|
|
|
someAlias, _ = NewAlias("012345678901234567890")
|
|
|
|
someSig, _ = btcec.ParseSignature(sigStr, btcec.S256())
|
|
|
|
someSigBytes = someSig.Serialize()
|
|
|
|
|
2017-02-17 12:29:23 +03:00
|
|
|
someAddress = &net.TCPAddr{IP: (net.IP)([]byte{0x7f, 0x0, 0x0, 0x1}), Port: 8333}
|
|
|
|
someOtherAddress, _ = net.ResolveTCPAddr("tcp", "[2001:db8:85a3:0:0:8a2e:370:7334]:80")
|
|
|
|
someAddresses = []net.Addr{someAddress, someOtherAddress}
|
2016-12-07 18:46:22 +03:00
|
|
|
|
2017-02-16 15:34:44 +03:00
|
|
|
maxUint32 uint32 = (1 << 32) - 1
|
|
|
|
maxUint24 uint32 = (1 << 24) - 1
|
|
|
|
maxUint16 uint16 = (1 << 16) - 1
|
|
|
|
|
2017-04-17 01:22:20 +03:00
|
|
|
someShortChannelID = ShortChannelID{
|
2016-12-07 18:46:22 +03:00
|
|
|
BlockHeight: maxUint24,
|
|
|
|
TxIndex: maxUint24,
|
|
|
|
TxPosition: maxUint16,
|
|
|
|
}
|
|
|
|
|
|
|
|
someRGB = RGB{
|
|
|
|
red: 255,
|
|
|
|
green: 255,
|
|
|
|
blue: 255,
|
|
|
|
}
|
2017-03-20 12:24:55 +03:00
|
|
|
|
|
|
|
someFeature = featureName("somefeature")
|
|
|
|
someFeatures = NewFeatureVector([]Feature{
|
|
|
|
{someFeature, OptionalFlag},
|
|
|
|
})
|
2015-12-31 09:28:14 +03:00
|
|
|
)
|