Skip to content

Commit

Permalink
adding missing varint byte to p2pkh change
Browse files Browse the repository at this point in the history
  • Loading branch information
theflyingcodr committed Jul 26, 2021
1 parent b2889d5 commit bad55a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion txchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ func (tx *Tx) canAddChange(available uint64, standardFees *Fee) bool {

changeOutputFee := uint64(varIntUpper)

changeP2pkhByteLen := 8 + 25 // 8 bytes for satoshi value + 25 bytes for p2pkh script (e.g. 76a914cc...05388ac)
// 8 bytes for satoshi value +1 for varint length + 25 bytes for p2pkh script (e.g. 76a914cc...05388ac)
changeP2pkhByteLen := 8 + 1 + 25
changeOutputFee += uint64(changeP2pkhByteLen * standardFees.MiningFee.Satoshis / standardFees.MiningFee.Bytes)

// not enough change to add a whole change output so don't add anything and return
Expand Down

0 comments on commit bad55a6

Please sign in to comment.