mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 12:14:21 +01:00
* scaffolding wallet * remove wallet db, add loader instead * wip * implement some wallet methods * signing and utxos * renaming * fee estimator * chain source options * config * application service * clark docker-compose * CLI refactor * v0 clark * v0.1 clark * fix SignTapscriptInput (btcwallet) * wallet.Broadcast, send via explora * fix ASP pubkey * Use lnd's btcwallet & Add rpc to get wallet staus * wip * unilateral exit * Fixes on watching for notifications and cli init * handle non-final BIP68 errors * Fixes * Fixes * Fix * a * fix onboard cosigners + revert tree validation * fix covenant e2e tests * fix covenantless e2e tests * fix container naming * fix lint error * update REAME.md * Add env var for wallet password --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
76 lines
1.9 KiB
Go
76 lines
1.9 KiB
Go
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/internal/core/domain"
|
|
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
|
)
|
|
|
|
func parseTxs(txs []string) ([]string, error) {
|
|
if len(txs) <= 0 {
|
|
return nil, fmt.Errorf("missing list of forfeit txs")
|
|
}
|
|
// TODO abstract this ?
|
|
// for _, tx := range txs {
|
|
// if _, err := psetv2.NewPsetFromBase64(tx); err != nil {
|
|
// return nil, fmt.Errorf("invalid tx format")
|
|
// }
|
|
// }
|
|
return txs, nil
|
|
}
|
|
|
|
func parseAddress(addr string) (string, *secp256k1.PublicKey, *secp256k1.PublicKey, error) {
|
|
if len(addr) <= 0 {
|
|
return "", nil, nil, fmt.Errorf("missing address")
|
|
}
|
|
return common.DecodeAddress(addr)
|
|
}
|
|
|
|
func parseReceivers(outs []*arkv1.Output) ([]domain.Receiver, error) {
|
|
receivers := make([]domain.Receiver, 0, len(outs))
|
|
for _, out := range outs {
|
|
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())
|
|
}
|
|
receivers = append(receivers, domain.Receiver{
|
|
Pubkey: pubkey,
|
|
Amount: out.GetAmount(),
|
|
OnchainAddress: addr,
|
|
})
|
|
}
|
|
return receivers, nil
|
|
}
|
|
|
|
func toRoundStage(stage domain.Stage) arkv1.RoundStage {
|
|
if stage.Failed {
|
|
return arkv1.RoundStage_ROUND_STAGE_FAILED
|
|
}
|
|
|
|
switch stage.Code {
|
|
case domain.RegistrationStage:
|
|
return arkv1.RoundStage_ROUND_STAGE_REGISTRATION
|
|
case domain.FinalizationStage:
|
|
if stage.Ended {
|
|
return arkv1.RoundStage_ROUND_STAGE_FINALIZED
|
|
}
|
|
return arkv1.RoundStage_ROUND_STAGE_FINALIZATION
|
|
default:
|
|
return arkv1.RoundStage_ROUND_STAGE_UNSPECIFIED
|
|
}
|
|
}
|