mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
Add reversible policy to pending vtxos (#311)
* [server] descriptor-based vtxo script * [server] fix unit tests * [sdk] descriptor based vtxo * empty config check & version flag support * fix: empty config check & version flag support (#309) * fix * [sdk] several fixes * [sdk][server] several fixes * [common][sdk] add reversible VtxoScript type, use it in async payment * [common] improve parser * [common] fix reversible vtxo parser * [sdk] remove logs * fix forfeit map * remove debug log * [sdk] do not allow reversible vtxo script in case of self-transfer * remove signing pubkey * remove signer public key, craft forfeit txs client side * go work sync * fix linter errors * rename MakeForfeitTxs to BuildForfeitTxs * fix conflicts * fix tests * comment VtxoScript type * revert ROUND_INTERVAL value --------- Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com> Co-authored-by: sekulicd <sekula87@gmail.com>
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/ark-network/ark/server/internal/core/application"
|
||||
"github.com/ark-network/ark/server/internal/core/domain"
|
||||
"github.com/ark-network/ark/server/internal/core/ports"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
)
|
||||
|
||||
@@ -18,27 +17,19 @@ func parseAddress(addr string) (string, *secp256k1.PublicKey, *secp256k1.PublicK
|
||||
return common.DecodeAddress(addr)
|
||||
}
|
||||
|
||||
func parseInputs(ins []*arkv1.Input) ([]application.Input, error) {
|
||||
func parseInputs(ins []*arkv1.Input) ([]ports.Input, error) {
|
||||
if len(ins) <= 0 {
|
||||
return nil, fmt.Errorf("missing inputs")
|
||||
}
|
||||
|
||||
inputs := make([]application.Input, 0, len(ins))
|
||||
inputs := make([]ports.Input, 0, len(ins))
|
||||
for _, input := range ins {
|
||||
if input.GetBoardingInput() != nil {
|
||||
desc := input.GetBoardingInput().GetDescriptor_()
|
||||
inputs = append(inputs, application.Input{
|
||||
Txid: input.GetBoardingInput().GetTxid(),
|
||||
Index: input.GetBoardingInput().GetVout(),
|
||||
Descriptor: desc,
|
||||
})
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
inputs = append(inputs, application.Input{
|
||||
Txid: input.GetVtxoInput().GetTxid(),
|
||||
Index: input.GetVtxoInput().GetVout(),
|
||||
inputs = append(inputs, ports.Input{
|
||||
VtxoKey: domain.VtxoKey{
|
||||
Txid: input.GetOutpoint().GetTxid(),
|
||||
VOut: input.GetOutpoint().GetVout(),
|
||||
},
|
||||
Descriptor: input.GetDescriptor_(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -51,21 +42,14 @@ func parseReceivers(outs []*arkv1.Output) ([]domain.Receiver, error) {
|
||||
if out.GetAmount() == 0 {
|
||||
return nil, fmt.Errorf("missing output amount")
|
||||
}
|
||||
if len(out.GetAddress()) <= 0 {
|
||||
return nil, fmt.Errorf("missing output address")
|
||||
}
|
||||
var pubkey, addr string
|
||||
_, pk, _, err := common.DecodeAddress(out.GetAddress())
|
||||
if err != nil {
|
||||
addr = out.GetAddress()
|
||||
}
|
||||
if pk != nil {
|
||||
pubkey = hex.EncodeToString(pk.SerializeCompressed())
|
||||
if len(out.GetAddress()) <= 0 && len(out.GetDescriptor_()) <= 0 {
|
||||
return nil, fmt.Errorf("missing output destination")
|
||||
}
|
||||
|
||||
receivers = append(receivers, domain.Receiver{
|
||||
Pubkey: pubkey,
|
||||
Descriptor: out.GetDescriptor_(),
|
||||
Amount: out.GetAmount(),
|
||||
OnchainAddress: addr,
|
||||
OnchainAddress: out.GetAddress(),
|
||||
})
|
||||
}
|
||||
return receivers, nil
|
||||
|
||||
Reference in New Issue
Block a user