Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinwendu20 authored and kaloudis committed Aug 21, 2024
1 parent 201195d commit 8e82e43
Show file tree
Hide file tree
Showing 43 changed files with 3,095 additions and 2,349 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
// Speedloader
replace github.com/breez/breez => github.com/djkazic/breez v0.0.8

replace github.com/btcsuite/btcwallet => github.com/ZeusLN/btcwallet v1.7.2-m
replace github.com/btcsuite/btcwallet => github.com/ZeusLN/btcwallet v1.7.2-m2

replace github.com/btcsuite/btcwallet/walletdb => github.com/djkazic/btcwallet/walletdb v1.7.2

Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344 h1:cDVUiFo+npB0ZASqnw4
github.com/Yawning/aez v0.0.0-20211027044916-e49e68abd344/go.mod h1:9pIqrY6SXNL8vjRQE5Hd/OL5GyK/9MrGUWs87z/eFfk=
github.com/ZeusLN/btcwallet v1.7.2-m h1:bO/c9KvoiAuzBn5vaSfqFix/gbWF/tNaRUQgNLguFC4=
github.com/ZeusLN/btcwallet v1.7.2-m/go.mod h1:X2xDre+j1QphTRo54y2TikUzeSvreL1t1aMXrD8Kc5A=
github.com/ZeusLN/btcwallet v1.7.2-m2 h1:0iJUkXlnGRgcY+Xm6PeSjzqrKKZB7J3gI+8W2xvKd70=
github.com/ZeusLN/btcwallet v1.7.2-m2/go.mod h1:X2xDre+j1QphTRo54y2TikUzeSvreL1t1aMXrD8Kc5A=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
Expand Down Expand Up @@ -543,6 +545,8 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chinwendu20/btcwallet v0.0.0-20240819210355-28272cf3b6e7 h1:Rf8LXcxdvssLEY7ooSplDQDEX7pWmQSrXc4f7NhqDCE=
github.com/chinwendu20/btcwallet v0.0.0-20240819210355-28272cf3b6e7/go.mod h1:X2xDre+j1QphTRo54y2TikUzeSvreL1t1aMXrD8Kc5A=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down
155 changes: 90 additions & 65 deletions itest/lnd_wallet_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,30 +545,57 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,
// Generate an address for carol and send coins to it,
// when we import carol's account into dave's,
// we would generate this address in dave's node and test that we can
// recover the funds that we sent to this address after a restart of
// Dave's node.
r := carol.RPC.NewAddress(&lnrpc.NewAddressRequest{
// recover the funds that we sent to this address after calling the
// rescan rpc.
carolAddrResp := carol.RPC.NewAddress(&lnrpc.NewAddressRequest{
Type: walletToLNAddrType(ht.T, addrType),
})

ht.FundCoins(100000, ht.Alice)

req := &lnrpc.SendCoinsRequest{
Addr: r.Address,
Addr: carolAddrResp.Address,
Amount: 8000,
SatPerByte: 1,
}
ht.Alice.RPC.SendCoins(req)
ht.MineBlocks(6)

// When the `rescan` RPC is called without specifying an address, it
// scans all blocks starting from the provided block height or the
// wallet's birthday block height (if no height is specified). The
// purpose of the scan is to detect transactions associated with all
// addresses in the wallet.

// In this test, we would simulate rescanning from a block that has
// already been scanned, with previously accounted transactions.
// We generate an address for Dave and send funds to it, then mine the
// transaction. This test verifies that, when the `rescan` RPC is
// invoked, the wallet does not incorrectly debit or credit funds that
// have already been accounted for previously.
daveAddrResp := dave.RPC.NewAddress(&lnrpc.NewAddressRequest{
Type: walletToLNAddrType(ht.T, addrType),
})

req = &lnrpc.SendCoinsRequest{
Addr: daveAddrResp.Address,
Amount: 5000,
SatPerByte: 1,
}
ht.Alice.RPC.SendCoins(req)

// Get the height of the block the transaction was mined in.
_, rescanStartHeight := ht.GetBestBlock()

ht.MineBlocksAndAssertNumTxes(6, 2)

ht.AssertWalletAccountBalance(carol, defaultAccount, 8000, 0)
ht.AssertWalletAccountBalance(dave, defaultAccount, 5000, 0)

const importedAccount = "carol"
importReq := &walletrpc.ImportAccountRequest{
Name: importedAccount,
ExtendedPublicKey: carolAccount.ExtendedPublicKey,
AddressType: addrType,
BirthdayHeight: 5,
}
dave.RPC.ImportAccount(importReq)

Expand Down Expand Up @@ -600,10 +627,6 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,
err := dave.RPC.ImportAccountAssertErr(importReq)
require.ErrorContains(ht, err, errAccountExists)

// externalAddr := newExternalAddr(
// ht, dave, carol, importedAccount, addrType,
// )

// We'll generate an address for Carol from Dave's node to receive some
// funds. This account should be the same as the address that we
// generated in carol's node.
Expand All @@ -614,67 +637,69 @@ func runWalletImportAccountScenario(ht *lntest.HarnessTest,

externalAddr := resp.Address

require.Equal(ht, r.Address, externalAddr)
require.Equal(ht, carolAddrResp.Address, externalAddr)

// We should only be able to recover the coins in this address after a
// restart.
// We should only be able to recover the coins in this address after
// calling the rescan rpc.
ht.AssertWalletAccountBalance(dave, importedAccount, 0, 0)

ht.RestartNode(dave)
dave.RPC.Rescan(&walletrpc.RescanRequest{
StartHeight: rescanStartHeight,
})

ht.AssertWalletAccountBalance(dave, importedAccount, 8000, 0)

// Send coins to Carol's address and confirm them, making sure the
// balance updates accordingly.
alice := ht.Alice
req = &lnrpc.SendCoinsRequest{
Addr: externalAddr,
Amount: utxoAmt,
SatPerByte: 1,
}
alice.RPC.SendCoins(req)

ht.AssertWalletAccountBalance(dave, importedAccount, 8000, utxoAmt)
ht.MineBlocksAndAssertNumTxes(1, 1)
ht.AssertWalletAccountBalance(dave, importedAccount, utxoAmt+8000, 0)

// To ensure that Dave can use Carol's account as watch-only, we'll
// construct a PSBT that sends funds to Alice, which we'll then hand
// over to Carol to sign.
psbtSendFromImportedAccount(
ht, dave, alice, carol, importedAccount, addrType,
)

// We'll generate a new address for Carol from Dave's node to receive
// and fund a new channel.
externalAddr = newExternalAddr(
ht, dave, carol, importedAccount, addrType,
)

// Retrieve the current confirmed balance of the imported account for
// some assertions we'll make later on.
balanceResp := dave.RPC.WalletBalance()
require.Contains(ht, balanceResp.AccountBalance, importedAccount)
confBalance := balanceResp.AccountBalance[importedAccount].
ConfirmedBalance

// Send coins to Carol's address and confirm them, making sure the
// balance updates accordingly.
req = &lnrpc.SendCoinsRequest{
Addr: externalAddr,
Amount: utxoAmt,
SatPerByte: 1,
}
alice.RPC.SendCoins(req)

ht.AssertWalletAccountBalance(
dave, importedAccount, confBalance, utxoAmt,
)
ht.MineBlocksAndAssertNumTxes(1, 1)
ht.AssertWalletAccountBalance(
dave, importedAccount, confBalance+utxoAmt, 0,
)

// // Send coins to Carol's address and confirm them, making sure the
// // balance updates accordingly.
// alice := ht.Alice
// req = &lnrpc.SendCoinsRequest{
// Addr: externalAddr,
// Amount: utxoAmt,
// SatPerByte: 1,
// }
// alice.RPC.SendCoins(req)
//
// ht.AssertWalletAccountBalance(dave, importedAccount, 8000, utxoAmt)
// ht.MineBlocksAndAssertNumTxes(1, 1)
// ht.AssertWalletAccountBalance(dave, importedAccount, utxoAmt+8000, 0)
//
// // To ensure that Dave can use Carol's account as watch-only, we'll
// // construct a PSBT that sends funds to Alice, which we'll then hand
// // over to Carol to sign.
// psbtSendFromImportedAccount(
// ht, dave, alice, carol, importedAccount, addrType,
// )
//
// // We'll generate a new address for Carol from Dave's node to receive
// // and fund a new channel.
// externalAddr = newExternalAddr(
// ht, dave, carol, importedAccount, addrType,
// )
//
// // Retrieve the current confirmed balance of the imported account for
// // some assertions we'll make later on.
// balanceResp := dave.RPC.WalletBalance()
// require.Contains(ht, balanceResp.AccountBalance, importedAccount)
// confBalance := balanceResp.AccountBalance[importedAccount].
// ConfirmedBalance
//
// // Send coins to Carol's address and confirm them, making sure the
// // balance updates accordingly.
// req = &lnrpc.SendCoinsRequest{
// Addr: externalAddr,
// Amount: utxoAmt,
// SatPerByte: 1,
// }
// alice.RPC.SendCoins(req)
//
// ht.AssertWalletAccountBalance(
// dave, importedAccount, confBalance, utxoAmt,
// )
// ht.MineBlocksAndAssertNumTxes(1, 1)
// ht.AssertWalletAccountBalance(
// dave, importedAccount, confBalance+utxoAmt, 0,
// )
//
// // Now that we have enough funds, it's time to fund the channel, make a
// // test payment, and close it. This contains several balance assertions
// // along the way.
Expand Down
Loading

0 comments on commit 8e82e43

Please sign in to comment.