Skip to content

Commit

Permalink
client/asset/btc: get locked balance for ZEC
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Oct 28, 2022
1 parent e4bdbf0 commit b3fddff
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/asset/btc/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1390,25 +1390,28 @@ func (btc *baseWallet) legacyBalance() (*asset.Balance, error) {
return nil, fmt.Errorf("legacyBalance unimplemented for spv clients")
}

locked, err := btc.lockedSats()
if err != nil {
return nil, fmt.Errorf("(legacy) lockedSats error: %w", err)
}

if btc.zecStyleBalance {
var bal uint64
// args: "(dummy)" minconf includeWatchonly inZat
if err := cl.call(methodGetBalance, anylist{"", 0, false, true}, &bal); err != nil {
return nil, err
}
return &asset.Balance{Available: bal}, nil
return &asset.Balance{
Available: bal - locked,
Locked: locked,
}, nil
}

walletInfo, err := cl.GetWalletInfo()
if err != nil {
return nil, fmt.Errorf("(legacy) GetWalletInfo error: %w", err)
}

locked, err := btc.lockedSats()
if err != nil {
return nil, fmt.Errorf("(legacy) lockedSats error: %w", err)
}

return &asset.Balance{
Available: toSatoshi(walletInfo.Balance+walletInfo.UnconfirmedBalance) - locked,
Immature: toSatoshi(walletInfo.ImmatureBalance),
Expand Down

0 comments on commit b3fddff

Please sign in to comment.