rpcserver: fix wrong unit used in PushAmountSat
This commit is contained in:
2 files changed
+11
-7
No files matched your search
@@ -374,10 +374,12 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
const customizedMinHtlc = 4200
|
const customizedMinHtlc = 4200
|
||||||
|
|
||||||
chanAmt := btcutil.Amount(100000)
|
chanAmt := btcutil.Amount(100000)
|
||||||
|
pushAmt := btcutil.Amount(1000)
|
||||||
chanPoint := openChannelAndAssert(
|
chanPoint := openChannelAndAssert(
|
||||||
t, net, alice, bob,
|
t, net, alice, bob,
|
||||||
lntest.OpenChannelParams{
|
lntest.OpenChannelParams{
|
||||||
Amt: chanAmt,
|
Amt: chanAmt,
|
||||||
|
PushAmt: pushAmt,
|
||||||
MinHtlc: customizedMinHtlc,
|
MinHtlc: customizedMinHtlc,
|
||||||
RemoteMaxHtlcs: aliceRemoteMaxHtlcs,
|
RemoteMaxHtlcs: aliceRemoteMaxHtlcs,
|
||||||
},
|
},
|
||||||
@@ -415,12 +417,12 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
aliceChannel := resp.Channels[0]
|
aliceChannel := resp.Channels[0]
|
||||||
|
|
||||||
// Since Alice is the initiator, she pays the commit fee.
|
// Since Alice is the initiator, she pays the commit fee.
|
||||||
aliceBalance := int64(chanAmt) - aliceChannel.CommitFee
|
aliceBalance := int64(chanAmt) - aliceChannel.CommitFee - int64(pushAmt)
|
||||||
|
|
||||||
// Check the balance related fields are correct.
|
// Check the balance related fields are correct.
|
||||||
require.Equal(t.t, aliceBalance, aliceChannel.LocalBalance)
|
require.Equal(t.t, aliceBalance, aliceChannel.LocalBalance)
|
||||||
require.Zero(t.t, aliceChannel.RemoteBalance)
|
require.EqualValues(t.t, pushAmt, aliceChannel.RemoteBalance)
|
||||||
require.Zero(t.t, aliceChannel.PushAmountSat)
|
require.EqualValues(t.t, pushAmt, aliceChannel.PushAmountSat)
|
||||||
|
|
||||||
// Calculate the dust limit we'll use for the test.
|
// Calculate the dust limit we'll use for the test.
|
||||||
dustLimit := lnwallet.DustLimitForSize(input.UnknownWitnessSize)
|
dustLimit := lnwallet.DustLimitForSize(input.UnknownWitnessSize)
|
||||||
@@ -474,8 +476,8 @@ func testListChannels(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Check the balance related fields are correct.
|
// Check the balance related fields are correct.
|
||||||
require.Equal(t.t, aliceBalance, bobChannel.RemoteBalance)
|
require.Equal(t.t, aliceBalance, bobChannel.RemoteBalance)
|
||||||
require.Zero(t.t, bobChannel.LocalBalance)
|
require.EqualValues(t.t, pushAmt, bobChannel.LocalBalance)
|
||||||
require.Zero(t.t, bobChannel.PushAmountSat)
|
require.EqualValues(t.t, pushAmt, bobChannel.PushAmountSat)
|
||||||
|
|
||||||
// Check channel constraints match. Alice's local channel constraint
|
// Check channel constraints match. Alice's local channel constraint
|
||||||
// should be equal to Bob's remote channel constraint, and her remote
|
// should be equal to Bob's remote channel constraint, and her remote
|
||||||
|
|||||||
+4
-2
@@ -4085,9 +4085,11 @@ func createRPCOpenChannel(r *rpcServer, dbChannel *channeldb.OpenChannel,
|
|||||||
// is the push amount. Otherwise, our starting balance is the push
|
// is the push amount. Otherwise, our starting balance is the push
|
||||||
// amount. If there is no push amount, these values will simply be zero.
|
// amount. If there is no push amount, these values will simply be zero.
|
||||||
if dbChannel.IsInitiator {
|
if dbChannel.IsInitiator {
|
||||||
channel.PushAmountSat = uint64(dbChannel.InitialRemoteBalance)
|
amt := dbChannel.InitialRemoteBalance.ToSatoshis()
|
||||||
|
channel.PushAmountSat = uint64(amt)
|
||||||
} else {
|
} else {
|
||||||
channel.PushAmountSat = uint64(dbChannel.InitialLocalBalance)
|
amt := dbChannel.InitialLocalBalance.ToSatoshis()
|
||||||
|
channel.PushAmountSat = uint64(amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dbChannel.LocalShutdownScript) > 0 {
|
if len(dbChannel.LocalShutdownScript) > 0 {
|
||||||
|
|||||||
Reference in new issue
Block a user