mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 04:04: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:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/ark-network/ark/common/tree"
|
||||
"github.com/ark-network/ark/server/internal/core/domain"
|
||||
"github.com/ark-network/ark/server/internal/core/ports"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@@ -180,14 +179,19 @@ func newForfeitTxsMap(txBuilder ports.TxBuilder) *forfeitTxsMap {
|
||||
return &forfeitTxsMap{&sync.RWMutex{}, make(map[string]*signedTx), txBuilder}
|
||||
}
|
||||
|
||||
func (m *forfeitTxsMap) push(txs []string) {
|
||||
func (m *forfeitTxsMap) push(txs []string) error {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
|
||||
for _, tx := range txs {
|
||||
signed, txid, _ := m.builder.VerifyTapscriptPartialSigs(tx)
|
||||
m.forfeitTxs[txid] = &signedTx{tx, signed}
|
||||
txid, err := m.builder.GetTxID(tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.forfeitTxs[txid] = &signedTx{tx, false}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *forfeitTxsMap) sign(txs []string) error {
|
||||
@@ -229,17 +233,6 @@ func (m *forfeitTxsMap) pop() (signed, unsigned []string) {
|
||||
return signed, unsigned
|
||||
}
|
||||
|
||||
func (m *forfeitTxsMap) view() []string {
|
||||
m.lock.RLock()
|
||||
defer m.lock.RUnlock()
|
||||
|
||||
txs := make([]string, 0, len(m.forfeitTxs))
|
||||
for _, tx := range m.forfeitTxs {
|
||||
txs = append(txs, tx.tx)
|
||||
}
|
||||
return txs
|
||||
}
|
||||
|
||||
// onchainOutputs iterates over all the nodes' outputs in the congestion tree and checks their onchain state
|
||||
// returns the sweepable outputs as ports.SweepInput mapped by their expiration time
|
||||
func findSweepableOutputs(
|
||||
@@ -313,26 +306,3 @@ func getSpentVtxos(payments map[string]domain.Payment) []domain.VtxoKey {
|
||||
}
|
||||
return vtxos
|
||||
}
|
||||
|
||||
type boardingInput struct {
|
||||
txId chainhash.Hash
|
||||
vout uint32
|
||||
boardingPubKey *secp256k1.PublicKey
|
||||
amount uint64
|
||||
}
|
||||
|
||||
func (b boardingInput) GetHash() chainhash.Hash {
|
||||
return b.txId
|
||||
}
|
||||
|
||||
func (b boardingInput) GetIndex() uint32 {
|
||||
return b.vout
|
||||
}
|
||||
|
||||
func (b boardingInput) GetAmount() uint64 {
|
||||
return b.amount
|
||||
}
|
||||
|
||||
func (b boardingInput) GetBoardingPubkey() *secp256k1.PublicKey {
|
||||
return b.boardingPubKey
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user