Browse Source

Transaction: return a slice, not the original Buffer

hk-custom-address
Daniel Cousens 8 years ago
parent
commit
cc1af7d6a3
  1. 7
      src/transaction.js

7
src/transaction.js

@ -255,10 +255,10 @@ Transaction.prototype.getId = function () {
return bufferReverse(this.getHash()).toString('hex')
}
Transaction.prototype.toBuffer = function (buffer, offset) {
Transaction.prototype.toBuffer = function (buffer, initialOffset) {
if (!buffer) buffer = new Buffer(this.byteLength())
offset = offset || 0
var offset = initialOffset || 0
function writeSlice (slice) {
slice.copy(buffer, offset)
offset += slice.length
@ -304,6 +304,9 @@ Transaction.prototype.toBuffer = function (buffer, offset) {
writeUInt32(this.locktime)
// avoid slicing unless necessary
if (initialOffset !== undefined) return buffer.slice(initialOffset, offset)
return buffer
}

Loading…
Cancel
Save