Skip to content

Commit

Permalink
Merge pull request #26 from phoreproject/remove_segwit_txs
Browse files Browse the repository at this point in the history
Remove segwit txs
  • Loading branch information
tohsnoom authored Jul 15, 2019
2 parents 24a870e + 2aecbad commit b3e476a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 35 deletions.
47 changes: 13 additions & 34 deletions bitcoin/phored/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var (
VERSION = "2.0.0"
VERSION = "2.0.1"
USERAGENT = "/Phore-Marketplace-go:" + VERSION + "/"
)

Expand Down

0 comments on commit b3e476a

Please sign in to comment.