[quote=“hrobeers, post:10, topic:3843”]We should encourage the support of peercoin in any wallet.
If you point me to the code that signs the transactions, I’ll look into the peercoin code what the difference is.
Peercoin should work quite similar to bitcoin tough.[/quote]
My wallet is opensource and use bitcoinjs-lib.
My code for transaction: https://github.com/3s3s/multicoins.org/blob/master/server_side/sendTransaction.js#L181
My code call library function: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction_builder.js#L405
Inside this function, signing itself occurs here: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction_builder.js#L479
In this place function call another final function: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction.js#L174
[code]Transaction.prototype.hashForSignature = function (inIndex, prevOutScript, hashType) {
typeforce(types.tuple(types.UInt32, types.Buffer, /* types.UInt8 */ types.Number), arguments)
// https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L29
if (inIndex >= this.ins.length) return ONE
var txTmp = this.clone()
// in case concatenating two scripts ends up with two codeseparators,
// or an extra one at the end, this prevents all those possible incompatibilities.
var hashScript = bscript.compile(bscript.decompile(prevOutScript).filter(function (x) {
return x !== opcodes.OP_CODESEPARATOR
}))
var i
// blank out other inputs’ signatures
txTmp.ins.forEach(function (input) { input.script = EMPTY_SCRIPT })
txTmp.ins[inIndex].script = hashScript
// blank out some of the inputs
if ((hashType & 0x1f) === Transaction.SIGHASH_NONE) {
// wildcard payee
txTmp.outs = []
// let the others update at will
txTmp.ins.forEach(function (input, i) {
if (i !== inIndex) {
input.sequence = 0
}
})
} else if ((hashType & 0x1f) === Transaction.SIGHASH_SINGLE) {
var nOut = inIndex
// only lock-in the txOut payee at same index as txIn
// https://github.com/bitcoin/bitcoin/blob/master/src/test/sighash_tests.cpp#L60
if (nOut >= this.outs.length) return ONE
txTmp.outs = txTmp.outs.slice(0, nOut + 1)
// blank all other outputs (clear scriptPubKey, value === -1)
var stubOut = {
script: EMPTY_SCRIPT,
valueBuffer: VALUE_UINT64_MAX
}
for (i = 0; i < nOut; i++) {
txTmp.outs[i] = stubOut
}
// let the others update at will
txTmp.ins.forEach(function (input, i) {
if (i !== inIndex) {
input.sequence = 0
}
})
}
// blank out other inputs completely, not recommended for open transactions
if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
txTmp.ins[0] = txTmp.ins[inIndex]
txTmp.ins = txTmp.ins.slice(0, 1)
}
// serialize and hash
var buffer = new Buffer(txTmp.byteLength() + 4)
buffer.writeInt32LE(hashType, buffer.length - 4)
txTmp.toBuffer().copy(buffer, 0)
return bcrypto.hash256(buffer)
}[/code]