diff --git a/README.md b/README.md index cedb146..7963d04 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Mainstay is accompanied by a Confirmation tool that can be run in parallel with - Unit Testing - - `/$GOPATH/src/mainstay/run-tests.sh` + - `/$GOPATH/src/mainstay/scripts/run-tests.sh` ## Tools diff --git a/attestation/attestclient.go b/attestation/attestclient.go index 3ce7161..afda9a9 100644 --- a/attestation/attestclient.go +++ b/attestation/attestclient.go @@ -366,7 +366,8 @@ func (w *AttestClient) createAttestation(paytoaddr btcutil.Address, unspent []bt msgTx.TxIn[0].Sequence = uint32(math.Pow(2, float64(32))) - 3 // return error if txout value is less than maxFee target - maxFee := calcSignedTxFee(w.Fees.maxFee, msgTx.SerializeSize(), len(w.script0)/2, w.numOfSigs) + maxFee := calcSignedTxFee(w.Fees.maxFee, msgTx.SerializeSize(), + len(inputs)*len(w.script0)/2, len(inputs)*w.numOfSigs) if msgTx.TxOut[0].Value < maxFee { return nil, errors.New(ErrorInsufficientFunds) } @@ -378,7 +379,8 @@ func (w *AttestClient) createAttestation(paytoaddr btcutil.Address, unspent []bt // add fees using best fee-per-byte estimate feePerByte := w.Fees.GetFee() - fee := calcSignedTxFee(feePerByte, msgTx.SerializeSize(), len(w.script0)/2, w.numOfSigs) + fee := calcSignedTxFee(feePerByte, msgTx.SerializeSize(), + len(inputs)*len(w.script0)/2, len(inputs)*w.numOfSigs) msgTx.TxOut[0].Value -= fee return msgTx, nil @@ -400,7 +402,8 @@ func (w *AttestClient) bumpAttestationFees(msgTx *wire.MsgTx) error { feePerByteIncrement := w.Fees.GetFee() - prevFeePerByte // increase tx fees by fee difference - feeIncrement := calcSignedTxFee(feePerByteIncrement, msgTx.SerializeSize(), len(w.script0)/2, w.numOfSigs) + feeIncrement := calcSignedTxFee(feePerByteIncrement, msgTx.SerializeSize(), + len(msgTx.TxIn)*len(w.script0)/2, len(msgTx.TxIn)*w.numOfSigs) msgTx.TxOut[0].Value -= feeIncrement return nil diff --git a/attestation/attestclient_test.go b/attestation/attestclient_test.go index 92c4caf..741d0e9 100644 --- a/attestation/attestclient_test.go +++ b/attestation/attestclient_test.go @@ -527,8 +527,10 @@ func TestAttestClient_FeeBumping(t *testing.T) { newFee := client.Fees.GetFee() newValue := tx2.TxOut[0].Value - newTxFee := calcSignedTxFee(newFee, tx2.SerializeSize(), len(client.script0)/2, client.numOfSigs) - currentTxFee := calcSignedTxFee(currentFee, tx.SerializeSize(), len(client.script0)/2, client.numOfSigs) + newTxFee := calcSignedTxFee(newFee, tx2.SerializeSize(), + len(tx2.TxIn)*len(client.script0)/2, len(tx2.TxIn)*client.numOfSigs) + currentTxFee := calcSignedTxFee(currentFee, tx.SerializeSize(), + len(tx.TxIn)*len(client.script0)/2, len(tx.TxIn)*client.numOfSigs) assert.Equal(t, newTxFee-currentTxFee, currentValue+topupValue-newValue) assert.Equal(t, client.Fees.minFee+client.Fees.feeIncrement, newFee)