From cce8f5b87c2d635c995fd959f745c826bd628daa Mon Sep 17 00:00:00 2001 From: anchaj Date: Mon, 15 Jul 2019 02:09:33 +0200 Subject: [PATCH 1/2] Remove segwit time lock verify transactions --- bitcoin/phored/wallet.go | 47 +++++++++++----------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/bitcoin/phored/wallet.go b/bitcoin/phored/wallet.go index a50f0055ab..0cadd19373 100644 --- a/bitcoin/phored/wallet.go +++ b/bitcoin/phored/wallet.go @@ -620,12 +620,10 @@ func (w *RPCWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Add }) // Check if time locked - var timeLocked bool if redeemScript != nil { rs := *redeemScript if rs[0] == txscript.OP_IF { - timeLocked = true - tx.Version = 2 + tx.Version = wire.TxVersion for _, txIn := range tx.TxIn { locktime, err := spvwallet.LockTimeFromRedeemScript(*redeemScript) if err != nil { @@ -636,47 +634,28 @@ func (w *RPCWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Add } } - hashes := txscript.NewTxSigHashes(tx) for i, txIn := range tx.TxIn { - if redeemScript == nil { - prevOutScript := additionalPrevScripts[txIn.PreviousOutPoint] - script, err := txscript.SignTxOutput(w.params, - tx, i, prevOutScript, txscript.SigHashAll, getKey, - getScript, txIn.SignatureScript) - if err != nil { - return nil, errors.New("Failed to sign transaction") - } - txIn.SignatureScript = script - } else { - sig, err := txscript.RawTxInWitnessSignature(tx, hashes, i, ins[i].Value, *redeemScript, txscript.SigHashAll, privKey) - if err != nil { - return nil, err - } - var witness wire.TxWitness - if timeLocked { - witness = wire.TxWitness{sig, []byte{}} - } else { - witness = wire.TxWitness{[]byte{}, sig} - } - witness = append(witness, *redeemScript) - txIn.Witness = witness + prevOutScript := additionalPrevScripts[txIn.PreviousOutPoint] + script, err := txscript.SignTxOutput(w.params, + tx, i, prevOutScript, txscript.SigHashAll, getKey, + getScript, txIn.SignatureScript) + if err != nil { + return nil, errors.New("Failed to sign transaction") } + txIn.SignatureScript = script } - // broadcast - //_, err = w.rpcClient.SendRawTransaction(tx, false) - //if err != nil { - // return nil, err - //} - - w.Broadcast(tx) + err = w.Broadcast(tx) + if err != nil { + log.Errorf("SweepAddress.Broadcast error: %s", err) + } txid := tx.TxHash() return &txid, nil } // GetFeePerByte gets the fee in pSAT per byte func (w *RPCWallet) GetFeePerByte(feeLevel wallet.FeeLevel) uint64 { - return 10 + return 25 } // Broadcast a transaction to the network From 2aecbad08605c70c12576a012c0769b8ac994619 Mon Sep 17 00:00:00 2001 From: anchaj Date: Mon, 15 Jul 2019 19:39:30 +0200 Subject: [PATCH 2/2] Bump version. --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 1ee1cd9e91..97bd8d4227 100644 --- a/core/core.go +++ b/core/core.go @@ -29,7 +29,7 @@ import ( ) var ( - VERSION = "2.0.0" + VERSION = "2.0.1" USERAGENT = "/Phore-Marketplace-go:" + VERSION + "/" )