mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 04:34:19 +01:00
Add support for collaborative redemption of vtxos & Changes to ark wallet (#72)
* Add internal support for collaborative exit * Update protos and interface layer * Fixes after proto updates * Fix printing json & Do not print ark pubkey in config * Add collaborative redeem command * Polish * Add address validation * Fix building tree without right branch * Fixes and validation checks * Fixes * Fix counting complete queued payments * Add relays * Add and compute onchain balance concurrently * Tiny refactor * Merge `config connect` into `init` cmd
This commit is contained in:
committed by
GitHub
parent
022bc67ab8
commit
d150c4bbac
@@ -1,10 +1,14 @@
|
||||
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"
|
||||
"github.com/vulpemventures/go-elements/address"
|
||||
"github.com/vulpemventures/go-elements/psetv2"
|
||||
)
|
||||
|
||||
@@ -20,13 +24,41 @@ func parseTxs(txs []string) ([]string, error) {
|
||||
return txs, nil
|
||||
}
|
||||
|
||||
func parseAddress(addr string) (*secp256k1.PublicKey, error) {
|
||||
func parseAddress(addr string) (string, *secp256k1.PublicKey, *secp256k1.PublicKey, error) {
|
||||
if len(addr) <= 0 {
|
||||
return nil, fmt.Errorf("missing address")
|
||||
return "", nil, nil, fmt.Errorf("missing address")
|
||||
}
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid address: %s", err)
|
||||
}
|
||||
return userPubkey, nil
|
||||
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 {
|
||||
if _, err := address.ToOutputScript(out.GetAddress()); err != nil {
|
||||
return nil, fmt.Errorf("invalid output address: unknown format")
|
||||
}
|
||||
if isConf, _ := address.IsConfidential(out.GetAddress()); isConf {
|
||||
return nil, fmt.Errorf("invalid output address: must be unconfidential")
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user