mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-19 05:04:21 +01:00
New address encoding (#356)
* [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
This commit is contained in:
@@ -68,9 +68,12 @@ func (p Payment) validate(ignoreOuts bool) error {
|
||||
return fmt.Errorf("missing outputs")
|
||||
}
|
||||
for _, r := range p.Receivers {
|
||||
if len(r.OnchainAddress) <= 0 && len(r.Descriptor) <= 0 {
|
||||
if len(r.OnchainAddress) <= 0 && len(r.Pubkey) <= 0 {
|
||||
return fmt.Errorf("missing receiver destination")
|
||||
}
|
||||
if r.Amount == 0 {
|
||||
return fmt.Errorf("missing receiver amount")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -80,6 +83,10 @@ type VtxoKey struct {
|
||||
VOut uint32
|
||||
}
|
||||
|
||||
func (k VtxoKey) String() string {
|
||||
return fmt.Sprintf("%s:%d", k.Txid, k.VOut)
|
||||
}
|
||||
|
||||
func (k VtxoKey) Hash() string {
|
||||
calcHash := func(buf []byte, hasher hash.Hash) []byte {
|
||||
_, _ = hasher.Write(buf)
|
||||
@@ -96,9 +103,9 @@ func (k VtxoKey) Hash() string {
|
||||
}
|
||||
|
||||
type Receiver struct {
|
||||
Descriptor string
|
||||
Amount uint64
|
||||
OnchainAddress string
|
||||
OnchainAddress string // onchain
|
||||
Pubkey string // offchain
|
||||
}
|
||||
|
||||
func (r Receiver) IsOnchain() bool {
|
||||
@@ -107,7 +114,8 @@ func (r Receiver) IsOnchain() bool {
|
||||
|
||||
type Vtxo struct {
|
||||
VtxoKey
|
||||
Receiver
|
||||
Amount uint64
|
||||
Pubkey string
|
||||
RoundTxid string
|
||||
SpentBy string // round txid or async redeem txid
|
||||
Spent bool
|
||||
|
||||
Reference in New Issue
Block a user