mirror of
https://github.com/aljazceru/ark.git
synced 2026-01-30 08: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:
@@ -78,6 +78,10 @@ type Outpoint struct {
|
||||
VOut uint32
|
||||
}
|
||||
|
||||
func (o Outpoint) Equals(other Outpoint) bool {
|
||||
return o.Txid == other.Txid && o.VOut == other.VOut
|
||||
}
|
||||
|
||||
type Input struct {
|
||||
Outpoint
|
||||
Descriptor string
|
||||
@@ -95,7 +99,7 @@ type Vtxo struct {
|
||||
RoundTxid string
|
||||
ExpiresAt *time.Time
|
||||
RedeemTx string
|
||||
Pending bool
|
||||
IsOOR bool
|
||||
SpentBy string
|
||||
}
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ func (c *grpcClient) GetTransactionsStream(
|
||||
Round: &client.RoundTransaction{
|
||||
Txid: tx.Round.Txid,
|
||||
SpentVtxos: outpointsFromProto(tx.Round.SpentVtxos),
|
||||
SpendableVtxos: vtxosFromProto(tx.Round.SpendableVtxos),
|
||||
SpendableVtxos: vtxos(tx.Round.SpendableVtxos).toVtxos(),
|
||||
ClaimedBoardingUtxos: outpointsFromProto(tx.Round.ClaimedBoardingUtxos),
|
||||
},
|
||||
}
|
||||
@@ -368,7 +368,7 @@ func (c *grpcClient) GetTransactionsStream(
|
||||
Redeem: &client.RedeemTransaction{
|
||||
Txid: tx.Redeem.Txid,
|
||||
SpentVtxos: outpointsFromProto(tx.Redeem.SpentVtxos),
|
||||
SpendableVtxos: vtxosFromProto(tx.Redeem.SpendableVtxos),
|
||||
SpendableVtxos: vtxos(tx.Redeem.SpendableVtxos).toVtxos(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -394,24 +394,3 @@ func outpointsFromProto(protoOutpoints []*arkv1.Outpoint) []client.Outpoint {
|
||||
}
|
||||
return outpoints
|
||||
}
|
||||
|
||||
func vtxosFromProto(protoVtxos []*arkv1.Vtxo) []client.Vtxo {
|
||||
vtxos := make([]client.Vtxo, len(protoVtxos))
|
||||
for i, v := range protoVtxos {
|
||||
expiresAt := time.Unix(v.ExpireAt, 0)
|
||||
vtxos[i] = client.Vtxo{
|
||||
Outpoint: client.Outpoint{
|
||||
Txid: v.Outpoint.Txid,
|
||||
VOut: v.Outpoint.Vout,
|
||||
},
|
||||
Pubkey: v.Pubkey,
|
||||
Amount: v.Amount,
|
||||
RoundTxid: v.RoundTxid,
|
||||
ExpiresAt: &expiresAt,
|
||||
RedeemTx: v.RedeemTx,
|
||||
Pending: v.Pending,
|
||||
SpentBy: v.SpentBy,
|
||||
}
|
||||
}
|
||||
return vtxos
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (v vtxo) toVtxo() client.Vtxo {
|
||||
Amount: v.GetAmount(),
|
||||
RoundTxid: v.GetRoundTxid(),
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.GetPending(),
|
||||
IsOOR: v.GetIsOor(),
|
||||
RedeemTx: v.GetRedeemTx(),
|
||||
SpentBy: v.GetSpentBy(),
|
||||
Pubkey: v.GetPubkey(),
|
||||
|
||||
@@ -499,7 +499,7 @@ func (a *restClient) ListVtxos(
|
||||
Amount: uint64(amount),
|
||||
RoundTxid: v.RoundTxid,
|
||||
ExpiresAt: expiresAt,
|
||||
Pending: v.Pending,
|
||||
IsOOR: v.IsOor,
|
||||
RedeemTx: v.RedeemTx,
|
||||
SpentBy: v.SpentBy,
|
||||
Pubkey: v.Pubkey,
|
||||
@@ -701,7 +701,7 @@ func vtxosFromRest(restVtxos []*models.V1Vtxo) []client.Vtxo {
|
||||
RoundTxid: v.RoundTxid,
|
||||
ExpiresAt: expiresAt,
|
||||
RedeemTx: v.RedeemTx,
|
||||
Pending: v.Pending,
|
||||
IsOOR: v.IsOor,
|
||||
SpentBy: v.SpentBy,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ type V1Vtxo struct {
|
||||
// expire at
|
||||
ExpireAt string `json:"expireAt,omitempty"`
|
||||
|
||||
// is oor
|
||||
IsOor bool `json:"isOor,omitempty"`
|
||||
|
||||
// outpoint
|
||||
Outpoint *V1Outpoint `json:"outpoint,omitempty"`
|
||||
|
||||
// pending
|
||||
Pending bool `json:"pending,omitempty"`
|
||||
|
||||
// pubkey
|
||||
Pubkey string `json:"pubkey,omitempty"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user