mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 04:34:19 +01:00
Make change of async payment spendable (#324)
* Drop unused ComputeOutputScript & use ParseTaprootScript internally * Add pending field to vtxo domain * Add check to handle async change as claimed vtxo & Move check to prevent spending penidng vtxos to app level * Rename utils.go to parser.go & Fixes * Ignore sent-and-reversible vtxos in ListVtxos * Fixes Co-authored-by: Louis Singer <louisinger@users.noreply.github.com> * Fix e2e test Co-authored-by: Louis Singer <louisinger@users.noreply.github.com> Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Fix * Add PendingChange field to vtxo * Add PendingChange field to Transaction * Fixes * Remove logs --------- Co-authored-by: Louis Singer <louisinger@users.noreply.github.com> Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
10ef0dbffa
commit
5c2065ad47
@@ -137,6 +137,26 @@ func LoadCovenantClientWithWallet(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *covenantArkClient) ListVtxos(
|
||||
ctx context.Context,
|
||||
) (spendableVtxos, spentVtxos []client.Vtxo, err error) {
|
||||
offchainAddrs, _, _, err := a.wallet.GetAddresses(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, addr := range offchainAddrs {
|
||||
spendable, spent, err := a.client.ListVtxos(ctx, addr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
spendableVtxos = append(spendableVtxos, spendable...)
|
||||
spentVtxos = append(spentVtxos, spent...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (a *covenantArkClient) Balance(
|
||||
ctx context.Context, computeVtxoExpiration bool,
|
||||
) (*Balance, error) {
|
||||
@@ -1654,16 +1674,10 @@ func (a *covenantArkClient) getBoardingTxs(ctx context.Context) (transactions []
|
||||
}
|
||||
|
||||
for _, u := range allUtxos {
|
||||
pending := false
|
||||
if isPending[u.Txid] {
|
||||
pending = true
|
||||
}
|
||||
transactions = append(transactions, Transaction{
|
||||
BoardingTxid: u.Txid,
|
||||
Amount: u.Amount,
|
||||
Type: TxReceived,
|
||||
Pending: pending,
|
||||
Claimed: !pending,
|
||||
CreatedAt: u.CreatedAt,
|
||||
})
|
||||
}
|
||||
@@ -1703,13 +1717,6 @@ func vtxosToTxsCovenant(
|
||||
if amount < 0 {
|
||||
txType = TxSent
|
||||
}
|
||||
// check if is a pending tx
|
||||
pending := false
|
||||
claimed := true
|
||||
if len(v.RoundTxid) == 0 && len(v.SpentBy) == 0 {
|
||||
pending = true
|
||||
claimed = false
|
||||
}
|
||||
// get redeem txid
|
||||
redeemTxid := ""
|
||||
if len(v.RedeemTx) > 0 {
|
||||
@@ -1725,8 +1732,6 @@ func vtxosToTxsCovenant(
|
||||
RedeemTxid: redeemTxid,
|
||||
Amount: uint64(math.Abs(float64(amount))),
|
||||
Type: txType,
|
||||
Pending: pending,
|
||||
Claimed: claimed,
|
||||
CreatedAt: getCreatedAtFromExpiry(roundLifetime, *v.ExpiresAt),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user