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:
Pietralberto Mazza
2024-09-19 19:44:22 +02:00
committed by GitHub
parent 10ef0dbffa
commit 5c2065ad47
34 changed files with 569 additions and 1054 deletions

View File

@@ -43,17 +43,18 @@ func (v *vxtoRepository) AddVtxos(ctx context.Context, vtxos []domain.Vtxo) erro
}
if err := querierWithTx.UpsertVtxo(
ctx, queries.UpsertVtxoParams{
Txid: vtxo.Txid,
Vout: int64(vtxo.VOut),
Descriptor: sql.NullString{String: vtxo.Descriptor, Valid: true},
Amount: int64(vtxo.Amount),
PoolTx: vtxo.PoolTx,
SpentBy: vtxo.SpentBy,
Spent: vtxo.Spent,
Redeemed: vtxo.Redeemed,
Swept: vtxo.Swept,
ExpireAt: vtxo.ExpireAt,
RedeemTx: sql.NullString{String: redeemTx, Valid: true},
Txid: vtxo.Txid,
Vout: int64(vtxo.VOut),
Descriptor: sql.NullString{String: vtxo.Descriptor, Valid: true},
Amount: int64(vtxo.Amount),
PoolTx: vtxo.PoolTx,
SpentBy: vtxo.SpentBy,
Spent: vtxo.Spent,
Redeemed: vtxo.Redeemed,
Swept: vtxo.Swept,
ExpireAt: vtxo.ExpireAt,
RedeemTx: sql.NullString{String: redeemTx, Valid: true},
PendingChange: sql.NullBool{Bool: vtxo.PendingChange, Valid: true},
},
); err != nil {
return err
@@ -301,13 +302,14 @@ func rowToVtxo(row queries.Vtxo, uncondForfeitTxs []queries.UncondForfeitTxVw) d
Descriptor: row.Descriptor.String,
Amount: uint64(row.Amount),
},
PoolTx: row.PoolTx,
SpentBy: row.SpentBy,
Spent: row.Spent,
Redeemed: row.Redeemed,
Swept: row.Swept,
ExpireAt: row.ExpireAt,
AsyncPayment: asyncPayment,
PoolTx: row.PoolTx,
SpentBy: row.SpentBy,
Spent: row.Spent,
Redeemed: row.Redeemed,
Swept: row.Swept,
ExpireAt: row.ExpireAt,
AsyncPayment: asyncPayment,
PendingChange: row.PendingChange.Bool,
}
}