lnwire+lnwallet+fundingmanager: general improvements
This commit is contained in:
1 parent
a6f7f05323
commit
5a82240c6a
13 files changed
+146
-108
No files matched your search
+2
-2
@@ -1585,7 +1585,7 @@ func (lc *LightningChannel) AddHTLC(htlc *lnwire.HTLCAddRequest) (uint32, error)
|
||||
EntryType: Add,
|
||||
RHash: PaymentHash(htlc.RedemptionHashes[0]),
|
||||
Timeout: htlc.Expiry,
|
||||
Amount: btcutil.Amount(htlc.Amount),
|
||||
Amount: htlc.Amount,
|
||||
Index: lc.ourLogCounter,
|
||||
}
|
||||
|
||||
@@ -1611,7 +1611,7 @@ func (lc *LightningChannel) ReceiveHTLC(htlc *lnwire.HTLCAddRequest) (uint32, er
|
||||
EntryType: Add,
|
||||
RHash: PaymentHash(htlc.RedemptionHashes[0]),
|
||||
Timeout: htlc.Expiry,
|
||||
Amount: btcutil.Amount(htlc.Amount),
|
||||
Amount: htlc.Amount,
|
||||
Index: lc.theirLogCounter,
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) {
|
||||
htlc := &lnwire.HTLCAddRequest{
|
||||
RedemptionHashes: [][32]byte{paymentHash},
|
||||
// TODO(roasbeef): properly switch to credits: (1 msat)
|
||||
Amount: lnwire.CreditsAmount(1e8),
|
||||
Amount: btcutil.Amount(1e8),
|
||||
Expiry: uint32(5),
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ func TestCheckCommitTxSize(t *testing.T) {
|
||||
|
||||
return &lnwire.HTLCAddRequest{
|
||||
RedemptionHashes: [][32]byte{paymentHash},
|
||||
Amount: lnwire.CreditsAmount(1e7),
|
||||
Amount: btcutil.Amount(1e7),
|
||||
Expiry: uint32(5),
|
||||
}, returnPreimage
|
||||
}
|
||||
@@ -742,7 +742,7 @@ func TestCheckHTLCNumberConstraint(t *testing.T) {
|
||||
paymentHash := fastsha256.Sum256(preimage)
|
||||
return &lnwire.HTLCAddRequest{
|
||||
RedemptionHashes: [][32]byte{paymentHash},
|
||||
Amount: lnwire.CreditsAmount(1e7),
|
||||
Amount: btcutil.Amount(1e7),
|
||||
Expiry: uint32(5),
|
||||
}
|
||||
}
|
||||
@@ -864,7 +864,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
rHash := fastsha256.Sum256(alicePreimage[:])
|
||||
h := &lnwire.HTLCAddRequest{
|
||||
RedemptionHashes: [][32]byte{rHash},
|
||||
Amount: lnwire.CreditsAmount(1000),
|
||||
Amount: btcutil.Amount(1000),
|
||||
Expiry: uint32(10),
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
rHash := fastsha256.Sum256(bobPreimage[:])
|
||||
bobh := &lnwire.HTLCAddRequest{
|
||||
RedemptionHashes: [][32]byte{rHash},
|
||||
Amount: lnwire.CreditsAmount(1000),
|
||||
Amount: btcutil.Amount(1000),
|
||||
Expiry: uint32(10),
|
||||
}
|
||||
bobChannel.AddHTLC(bobh)
|
||||
|
||||
@@ -908,12 +908,6 @@ func testSingleFunderReservationWorkflowResponder(miner *rpctest.Harness,
|
||||
// TODO(roasbeef): bob verify alice's sig
|
||||
}
|
||||
|
||||
func testFundingReservationInvalidCounterpartySigs(miner *rpctest.Harness, lnwallet *lnwallet.LightningWallet, t *testing.T) {
|
||||
}
|
||||
|
||||
func testFundingTransactionTxFees(miner *rpctest.Harness, lnwallet *lnwallet.LightningWallet, t *testing.T) {
|
||||
}
|
||||
|
||||
func testListTransactionDetails(miner *rpctest.Harness, wallet *lnwallet.LightningWallet, t *testing.T) {
|
||||
t.Log("Running list transaction details test")
|
||||
|
||||
@@ -1234,10 +1228,10 @@ var walletTests = []func(miner *rpctest.Harness, w *lnwallet.LightningWallet, te
|
||||
testSingleFunderReservationWorkflowResponder,
|
||||
testFundingTransactionLockedOutputs,
|
||||
testFundingCancellationNotEnoughFunds,
|
||||
testFundingReservationInvalidCounterpartySigs,
|
||||
testTransactionSubscriptions,
|
||||
testListTransactionDetails,
|
||||
testSignOutputPrivateTweak,
|
||||
testCancelNonExistantReservation,
|
||||
}
|
||||
|
||||
type testLnWallet struct {
|
||||
@@ -1324,28 +1318,28 @@ func TestLightningWallet(t *testing.T) {
|
||||
}
|
||||
|
||||
// Funding via 20 outputs with 4BTC each.
|
||||
lnwallet, err := createTestWallet(tempTestDir, miningNode, netParams,
|
||||
lnw, err := createTestWallet(tempTestDir, miningNode, netParams,
|
||||
chainNotifier, wc, signer, bio)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create test ln wallet: %v", err)
|
||||
}
|
||||
|
||||
// The wallet should now have 80BTC available for spending.
|
||||
assertProperBalance(t, lnwallet, 1, 80)
|
||||
assertProperBalance(t, lnw, 1, 80)
|
||||
|
||||
// Execute every test, clearing possibly mutated wallet state after
|
||||
// each step.
|
||||
for _, walletTest := range walletTests {
|
||||
walletTest(miningNode, lnwallet, t)
|
||||
walletTest(miningNode, lnw, t)
|
||||
|
||||
// TODO(roasbeef): possible reset mining node's chainstate to
|
||||
// initial level, cleanly wipe buckets
|
||||
if err := clearWalletState(lnwallet); err != nil &&
|
||||
if err := clearWalletState(lnw); err != nil &&
|
||||
err != bolt.ErrBucketNotFound {
|
||||
t.Fatalf("unable to wipe wallet state: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
lnwallet.Shutdown()
|
||||
lnw.Shutdown()
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
// ChannelContribution is the primary constituent of the funding workflow within
|
||||
// lnwallet. Each side first exchanges their respective contributions along with
|
||||
// channel specific paramters like the min fee/KB. Once contributions have been
|
||||
// channel specific parameters like the min fee/KB. Once contributions have been
|
||||
// exchanged, each side will then produce signatures for all their inputs to the
|
||||
// funding transactions, and finally a signature for the other party's version
|
||||
// of the commitment transaction.
|
||||
@@ -98,10 +98,6 @@ type ChannelReservation struct {
|
||||
// fundingTx is the funding transaction for this pending channel.
|
||||
fundingTx *wire.MsgTx
|
||||
|
||||
// For CLTV it is nLockTime, for CSV it's nSequence, for segwit it's
|
||||
// not needed
|
||||
fundingLockTime uint32
|
||||
|
||||
// In order of sorted inputs. Sorting is done in accordance
|
||||
// to BIP-69: https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki.
|
||||
ourFundingInputScripts []*InputScript
|
||||
@@ -228,7 +224,7 @@ func (r *ChannelReservation) OurContribution() *ChannelContribution {
|
||||
return r.ourContribution
|
||||
}
|
||||
|
||||
// ProcesContribution verifies the counterparty's contribution to the pending
|
||||
// ProcessContribution verifies the counterparty's contribution to the pending
|
||||
// payment channel. As a result of this incoming message, lnwallet is able to
|
||||
// build the funding transaction, and both commitment transactions. Once this
|
||||
// message has been processed, all signatures to inputs to the funding
|
||||
|
||||
@@ -768,7 +768,6 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
||||
|
||||
// With the funding tx complete, create both commitment transactions.
|
||||
// TODO(roasbeef): much cleanup + de-duplication
|
||||
pendingReservation.fundingLockTime = theirContribution.CsvDelay
|
||||
ourBalance := ourContribution.FundingAmount
|
||||
theirBalance := theirContribution.FundingAmount
|
||||
ourCommitKey := ourContribution.CommitKey
|
||||
|
||||
Reference in new issue
Block a user