lnwallet: save redeemScript in channel state
This commit is contained in:
parent
15f15bb3af
commit
5840786922
@ -2,7 +2,6 @@ package lnwallet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
@ -37,8 +36,6 @@ var (
|
|||||||
|
|
||||||
// Which bitcoin network are we using?
|
// Which bitcoin network are we using?
|
||||||
ActiveNetParams = &chaincfg.TestNet3Params
|
ActiveNetParams = &chaincfg.TestNet3Params
|
||||||
|
|
||||||
endian = binary.BigEndian
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type FundingType uint16
|
type FundingType uint16
|
||||||
@ -286,6 +283,13 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// InitChannelReservation...
|
// InitChannelReservation...
|
||||||
|
// fields set after completion:
|
||||||
|
// * ourInputs
|
||||||
|
// * ourChange
|
||||||
|
// * ourMultisigKey
|
||||||
|
// * ourCommitKey
|
||||||
|
// * ourDeliveryAddress
|
||||||
|
// * ourShaChain
|
||||||
func (l *LightningWallet) InitChannelReservation(a btcutil.Amount, t FundingType) (*ChannelReservation, error) {
|
func (l *LightningWallet) InitChannelReservation(a btcutil.Amount, t FundingType) (*ChannelReservation, error) {
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
respChan := make(chan *ChannelReservation, 1)
|
respChan := make(chan *ChannelReservation, 1)
|
||||||
@ -544,7 +548,10 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
|||||||
req.err <- err
|
req.err <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pendingReservation.partialState.fundingRedeemScript = redeemScript
|
|
||||||
|
// TODO(roasbeef): do Manager.ImportScript(..) here, gives us a
|
||||||
|
// ManagedScriptAddress to play around with if we need it.
|
||||||
|
pendingReservation.partialState.FundingRedeemScript = redeemScript
|
||||||
fundingTx.AddTxOut(multiSigOut)
|
fundingTx.AddTxOut(multiSigOut)
|
||||||
|
|
||||||
// Sort the transaction. Since both side agree to a cannonical
|
// Sort the transaction. Since both side agree to a cannonical
|
||||||
@ -726,6 +733,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
|||||||
|
|
||||||
// Add the complete funding transaction to the DB, in it's open bucket
|
// Add the complete funding transaction to the DB, in it's open bucket
|
||||||
// which will be used for the lifetime of this channel.
|
// which will be used for the lifetime of this channel.
|
||||||
|
// TODO(roasbeef): serialize OpenChannelState state to disk instead now
|
||||||
writeErr := l.lnNamespace.Update(func(tx walletdb.Tx) error {
|
writeErr := l.lnNamespace.Update(func(tx walletdb.Tx) error {
|
||||||
// Get the bucket dedicated to storing the meta-data for open
|
// Get the bucket dedicated to storing the meta-data for open
|
||||||
// channels.
|
// channels.
|
||||||
@ -758,6 +766,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
|||||||
// * will need a multi-plexer to fan out, to listen on ListenConnectedBlocks
|
// * will need a multi-plexer to fan out, to listen on ListenConnectedBlocks
|
||||||
// * should prob be a separate struct/modele
|
// * should prob be a separate struct/modele
|
||||||
// * use NotifySpent in order to catch non-cooperative spends of revoked
|
// * use NotifySpent in order to catch non-cooperative spends of revoked
|
||||||
|
// * NotifySpent(outpoints []*wire.OutPoint)
|
||||||
// commitment txns. Hmm using p2sh or bare multi-sig?
|
// commitment txns. Hmm using p2sh or bare multi-sig?
|
||||||
msg.err <- writeErr
|
msg.err <- writeErr
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ var (
|
|||||||
0x1e, 0xb, 0x4c, 0xfd, 0x9e, 0xc5, 0x8c, 0xe9,
|
0x1e, 0xb, 0x4c, 0xfd, 0x9e, 0xc5, 0x8c, 0xe9,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a hard-coded HD seed in order to avoid derivation.
|
// Use a hard-coded HD seed.
|
||||||
testHdSeed = []byte{
|
testHdSeed = []byte{
|
||||||
0xb7, 0x94, 0x38, 0x5f, 0x2d, 0x1e, 0xf7, 0xab,
|
0xb7, 0x94, 0x38, 0x5f, 0x2d, 0x1e, 0xf7, 0xab,
|
||||||
0x4d, 0x92, 0x73, 0xd1, 0x90, 0x63, 0x81, 0xb4,
|
0x4d, 0x92, 0x73, 0xd1, 0x90, 0x63, 0x81, 0xb4,
|
||||||
|
Loading…
Reference in New Issue
Block a user