mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
Add support for Out Of Round txs (#359)
* [common] rework address encoding * new address encoding * replace offchain address by vtxo output key in DB * merge migrations files into init one * fix txbuilder fixtures * fix transaction events * OOR scheme * fix conflicts * [sdk] OOR * update WASM wrappers * revert renaming * revert API changes * update parser.go * fix vtxosToTxsCovenantless * add settled and spent in Utxo and Transaction * Fixes (#5) * Revert unneeded changes and rename claim to settle * Revert changes to wasm and rename claim to settle --------- Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
This commit is contained in:
@@ -270,6 +270,27 @@ func (a *arkClient) ping(
|
||||
return ticker.Stop
|
||||
}
|
||||
|
||||
func (a *arkClient) 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.Address)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
spendableVtxos = append(spendableVtxos, spendable...)
|
||||
spentVtxos = append(spentVtxos, spent...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func getClient(
|
||||
supportedClients utils.SupportedType[utils.ClientFactory], clientType, aspUrl string,
|
||||
) (client.ASPClient, error) {
|
||||
@@ -329,3 +350,15 @@ func getWalletStore(storeType, datadir string) (walletstore.WalletStore, error)
|
||||
func getCreatedAtFromExpiry(roundLifetime int64, expiry time.Time) time.Time {
|
||||
return expiry.Add(-time.Duration(roundLifetime) * time.Second)
|
||||
}
|
||||
|
||||
func filterByOutpoints(vtxos []client.Vtxo, outpoints []client.Outpoint) []client.Vtxo {
|
||||
filtered := make([]client.Vtxo, 0, len(vtxos))
|
||||
for _, vtxo := range vtxos {
|
||||
for _, outpoint := range outpoints {
|
||||
if vtxo.Outpoint.Equals(outpoint) {
|
||||
filtered = append(filtered, vtxo)
|
||||
}
|
||||
}
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user