Sendrawtransaction not working

[member=30004]thehuntergames[/member] I believe you found it.

The serialization of the transaction in hashForSignature is the only difference I found so far.

Do you know why peercoin has that timestamp? What is it used for?

the timestamp among other data is used for hashing proof of stake.

i wrote something about it here long ago:
https://www.peercointalk.org/index.php?topic=3802.msg36829#msg36829

[quote=“thehuntergames, post:20, topic:3843”]I ve just made a fork with the sole purpose of having a peercoinjs.

So far I adjusted only a few files: network,transaction and transactionbuilder.

I’ll soon start adjusting some test files to see if i can create a raw tx for peercoin. I cant think of why signing a tx should be any different than in bitcoin[/quote]

I’ve just seen your changes. You only add timestamp to raw transaction. But my transactions already have timestamps:

[quote=“kzv, post:4, topic:3843”]still not working

 curl --user kzv:pass  --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendrawtransaction", "params": ["01000000e42a0e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006b4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff02a0860100000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac905f0100000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000"] }' -H 'content-type: text/plain;' http://127.0.0.1:9902/

result

{"result":"02fa4bcd9f074e42a9e6b66ab588116b503392ef6e5558e40a5d21b5e9d3e3dc","error":null,"id":"curltest"}

Input 0.2 PPC
Output 0.19 PPC

“Search failed, could not find anything!”
https://bkchain.org/ppc/search?search=02fa4bcd9f074e42a9e6b66ab588116b503392ef6e5558e40a5d21b5e9d3e3dc[/quote]

[“01000000e42a0e57019f9d0cca16ff2ee34efa067ae8850d8b8430caf84ab74eb2d2b52ea9cedc1af2010000006b4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561faffffffff02a0860100000000001976a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac905f0100000000001976a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac00000000”]

Red is timestamp.
I guess that hashing algoritm or digital signature algoritm for peercoin some differ from bitcoin one?

Edit: also you modify the file " bitcoinjs-lib/src/networks.js" with this values:

peercoin: { messagePrefix: '\x19Peercoin Signed Message:\n', bip32: { public: 0x0488b21e, private: 0x0488ade4 // ?? }, pubKeyHash: 0x37, scriptHash: 0x05, wif: 0xb7, dustThreshold: 0 // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01 }

my code some differ:

I took these values ​​from here https://github.com/bitcoinjs/bitcoinjs-lib/commit/03ef7fd1c7397b960e8d955e3d11ab8bc4f4626b

okay
cool, it seems visvirial already extended the library with peercoin support?.
His idea of adding an extra isPos in the networkobject is quite alright.
Have you tried sending him (in case you are not that person) a message about it?
I don’t think signing data is any different but I am out of my league here…
I wonder why it has not been pulled and merged with its parent yet…

i believe bip32 hasn’t been implemented yet, so his proposal of
bip32: {
public: 0x01da950b, // start with “Ppub…”
private: 0x01da90d0 // start with “Pprv…”
},
is as good as any. First implementation wins I’ll say.

I dont know anything about scriptHash (yet), but if this refers to pay to script hash, i believe peercoin does not (yet) have that either…

The transaction input only holds 0.21PPC (http://ppc.blockr.io/tx/info/f21adccea92eb5d2b24eb74af8ca30848b0d85e87a06fa4ee32eff16ca0c9d9f) While the outputs sum to 18PPC.

Another difference in peercoin is that the minimum is not satoshi but 100 times that.
so 1 ppc = 1000000 units whereas 1 btc = 100000000 satoshis.

so 18ppc ought to be 0.18ppc instead?

[quote=“thehuntergames, post:24, topic:3843”]okay
cool, it seems visvirial already extended the library with peercoin support?.
His idea of adding an extra isPos in the networkobject is quite alright.
Have you tried sending him (in case you are not that person) a message about it?
I don’t think signing data is any different but I am out of my league here…
I wonder why it has not been pulled and merged with its parent yet…

i believe bip32 hasn’t been implemented yet, so his proposal of
bip32: {
public: 0x01da950b, // start with “Ppub…”
private: 0x01da90d0 // start with “Pprv…”
},
is as good as any. First implementation wins I’ll say.

I dont know anything about scriptHash (yet), but if this refers to pay to script hash, i believe peercoin does not (yet) have that either…[/quote]

No, i’ve not contacted him.

I’ve just checked how peercoin signature for messages is working… It very strange for me!
when I sign the same message several times, i have got different valid signatures!!!

curl --user kzv:pass --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "signmessage", "params": ["PQrw7SoJsMWhYVoJW6DPdkjwEtAPmubQ85", "1"] }' -H 'content-type: text/plain;' http://127.0.0.1:9902/ {"result":"IIyb1HAL3tRVnk1FCL+WvpgZQ9dZd4Sl8UQzbxRgG53EerMFaz6S0dXpylZbW0c5CtFR0cntC0GlBt8ixNaazBY=","error":null,"id":"curltest"}

curl --user kzv:pass --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "signmessage", "params": ["PQrw7SoJsMWhYVoJW6DPdkjwEtAPmubQ85", "1"] }' -H 'content-type: text/plain;' http://127.0.0.1:9902/ {"result":"IJi0C4hZh7iCIDR2JPny3jP10nb9ymvxWEoDxLe86Ho+JLc0ZKCMAQma2J/Fns7TryMC5/PA5yyY2+7ALLhakWA=","error":null,"id":"curltest"}

All signatures is valid!
How is this possible???

[quote=“thehuntergames, post:25, topic:3843”]

The transaction input only holds 0.21PPC (http://ppc.blockr.io/tx/info/f21adccea92eb5d2b24eb74af8ca30848b0d85e87a06fa4ee32eff16ca0c9d9f)
While the outputs sum to 18PPC.

Another difference in peercoin is that the minimum is not satoshi but 100 times that.
so 1 ppc = 1000000 units whereas 1 btc = 100000000 satoshis.

so 18ppc ought to be 0.18ppc instead?[/quote]

Yes , I have already corrected this mistake

i took the liberty to decodetherawtransaction with a debug window:

{ "txid": "02fa4bcd9f074e42a9e6b66ab588116b503392ef6e5558e40a5d21b5e9d3e3dc", "version": 1, "time": 1460546276, "locktime": 0, "vin": [{ "txid": "f21adccea92eb5d2b24eb74af8ca30848b0d85e87a06fa4ee32eff16ca0c9d9f", "vout": 1, "scriptSig": { "asm": "30450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f01 020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561fa", "hex": "4830450221009e9a121235849ae2b1626dad111cc1ae9abf9553d1a08704aadede417a4788f10220413ca16a4549e0f11fe20d20ce50155359d6212298687fcf9a8c42a24496c69f0121020c695ebec7971d0c9abf28d9c84eabf124cc3665ca28261a0fd03ca0c89561fa" }, "sequence": 4294967295 }], "vout": [{ "value": 0.10000000, "n": 0, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 94827526e430e37be8e5fb0dd20dabf30d75bf52 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a91494827526e430e37be8e5fb0dd20dabf30d75bf5288ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "PN8RSidxVecoyhWK81Ea5iUFxF3LXTD5FH" ] } }, { "value": 0.09000000, "n": 1, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 b27cf1e7a30be8e0917e50d665ca70a2cec83b1e OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a914b27cf1e7a30be8e0917e50d665ca70a2cec83b1e88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "PQrw7SoJsMWhYVoJW6DPdkjwEtAPmubQ85" ] } }] }

from what i gather the raw transaction has to be signed

as e.g. in signrawtransaction [{“txid”:txid,“vout”:n,“scriptPubKey”:hex},…] [,…] [sighash=“ALL”]

before you can do something like this:

sendrawtransaction “signedhex”

question:
What is the difference after signing when you do this with rpc command iso bitcoinjs?

I’ve cloned the multicoins repo and am able to run the client locally.

I can debug both codes side by side to find a difference if you like.

However, I can’t find a branch on github containing your peercoin updates.

[quote=“thehuntergames, post:28, topic:3843”]question:
What is the difference after signing when you do this with rpc command iso bitcoinjs?[/quote]

I do not know!
When i sign transaction (or message) with bitcoinjs, peercoin client does not understand this signature :frowning:

[quote=“hrobeers, post:29, topic:3843”]I’ve cloned the multicoins repo and am able to run the client locally.

I can debug both codes side by side to find a difference if you like.

However, I can’t find a branch on github containing your peercoin updates.[/quote]

I’ve just make new branch “peercoin” but it is not contain node.js dependencies.

The fastest way to start working with the code - install it from npm: “npm install multicoins”

To start server:

  1. cd ./node_modules/multicoins

  2. node main.js

“/node_modules/multicoins/main.js” - web server

“/node_modules/multicoins/constants.js” - http and https ports (you can change it)

“/node_modules/multicoins/site/index.html” - main page

“/node_modules/multicoins/site/js/wallet.js” - main javascript. This script generate from “server_side” folder by command:

“browserify --debug /node_modules/multicoins/server_side/htmlEvents.js /node_modules/multicoins/server_side/modalEvents.js -s htmlEvents > /node_modules/multicoins/site/js/wallet.js”

I ve made a testscript in the test folder like this:


var assert = require('assert')
var baddress = require('../src/address')
var bscript = require('../src/script')
var ops = require('../src/opcodes')

var BigInteger = require('bigi')
var ECPair = require('../src/ecpair')
var Transaction = require('../src/transaction')
var TransactionBuilder = require('../src/transaction_builder')
var NETWORKS = require('../src/networks')

var fixtures = require('./fixtures/transaction_builder')

function construct (f, sign) {
  var network = NETWORKS[f.network]
  var txb = new TransactionBuilder(network)

  // FIXME: add support for version in TransactionBuilder API
  if (f.version !== undefined) {
    txb.tx.version = f.version
  }

  if (f.locktime !== undefined) {
    txb.setLockTime(f.locktime)
  }

  f.inputs.forEach(function (input) {
    var prevTxScript

    if (input.prevTxScript) {
      prevTxScript = bscript.fromASM(input.prevTxScript)
    }

    txb.addInput(input.txId, input.vout, input.sequence, prevTxScript)
  })

  f.outputs.forEach(function (output) {
    txb.addOutput(bscript.fromASM(output.script), output.value)
  })

  if (sign === undefined || sign) {
    f.inputs.forEach(function (input, index) {
      input.signs.forEach(function (sign) {
        var keyPair = ECPair.fromWIF(sign.keyPair, network)
        var redeemScript

        if (sign.redeemScript) {
          redeemScript = bscript.fromASM(sign.redeemScript)
        }

        txb.sign(index, keyPair, redeemScript, sign.hashType)
      })
    })
  }
  //txb.setTxTime(Math.round((new Date()).getTime() / 1000)); // this is new every time
  txb.setTxTime(1460720205)
  return txb
}
////////////////////////////////
console.log("start Session")
// does not have a change address!!!
var mytxval =  {
        "description": "Transaction w/ pubKeyHash -> pubKeyHash",
        "network": "peercoin",
        "txHex": "010000004dd2105701218496ee633f4ef4868805bbfc96109cd9fbc4d61497787fbb70df618d04a6bb010000006a47304402205b0ca994f998c888f1fc41099833e9ca0c1e8850d701c3d694490f535dc6189002201239ad538887d11a3ab70681498c786b2fff910b9e7829c495622f162667ee200121035664d77753a914dff49fc6d5be50bd69e3f9385bbaa9d7229c0f6d3bebaab7abffffffff0110270000000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000",
        "inputs": [
          {
            "txId": "bba6048d61df70bb7f789714d6c4fbd99c1096fcbb058886f44e3f63ee968421",
            "vout": 1,
            "signs": [
              {
                "keyPair": "UDUbFUCAPJiTsZFsSYYGyGMjWG6qUG4eupoggjp5qTf4YTKwY9TU"
              }
            ]
          }
        ],
        "outputs": [
          {
            "script": "OP_DUP OP_HASH160 fa2a8018355c004a9493f5df5fe3dd399f382997 OP_EQUALVERIFY OP_CHECKSIG",
            "value": 10000
          }
        ]
      };
 
 var txb = construct(mytxval)
 var tx = txb.build()
 var test1=tx.toHex();
        
console.log("Session: %j", test1);

if (test1!=mytxval.txHex) console.log("tx not equal");

I have not yet done sendrawtransaction 010000004dd2105701218496ee633f4ef4868805bbfc96109cd9fbc4d61497787fbb70df618d04a6bb010000006a47304402205b0ca994f998c888f1fc41099833e9ca0c1e8850d701c3d694490f535dc6189002201239ad538887d11a3ab70681498c786b2fff910b9e7829c495622f162667ee200121035664d77753a914dff49fc6d5be50bd69e3f9385bbaa9d7229c0f6d3bebaab7abffffffff0110270000000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000

as I am waiting for 6 conformations but I dont see why this should not work.

At this point I strongly suggest to switch to testnet as the conformation time is only 1 minute i believe… The values for testnet can be found here https://wiki.peercointalk.org/index.php?title=Peercoin_developer_notes

[quote=“thehuntergames, post:31, topic:3843”]I ve made a testscript in the test folder like this:


var assert = require('assert')
var baddress = require('../src/address')
var bscript = require('../src/script')
var ops = require('../src/opcodes')

var BigInteger = require('bigi')
var ECPair = require('../src/ecpair')
var Transaction = require('../src/transaction')
var TransactionBuilder = require('../src/transaction_builder')
var NETWORKS = require('../src/networks')

var fixtures = require('./fixtures/transaction_builder')

function construct (f, sign) {
  var network = NETWORKS[f.network]
  var txb = new TransactionBuilder(network)

  // FIXME: add support for version in TransactionBuilder API
  if (f.version !== undefined) {
    txb.tx.version = f.version
  }

  if (f.locktime !== undefined) {
    txb.setLockTime(f.locktime)
  }

  f.inputs.forEach(function (input) {
    var prevTxScript

    if (input.prevTxScript) {
      prevTxScript = bscript.fromASM(input.prevTxScript)
    }

    txb.addInput(input.txId, input.vout, input.sequence, prevTxScript)
  })

  f.outputs.forEach(function (output) {
    txb.addOutput(bscript.fromASM(output.script), output.value)
  })

  if (sign === undefined || sign) {
    f.inputs.forEach(function (input, index) {
      input.signs.forEach(function (sign) {
        var keyPair = ECPair.fromWIF(sign.keyPair, network)
        var redeemScript

        if (sign.redeemScript) {
          redeemScript = bscript.fromASM(sign.redeemScript)
        }

        txb.sign(index, keyPair, redeemScript, sign.hashType)
      })
    })
  }
  //txb.setTxTime(Math.round((new Date()).getTime() / 1000)); // this is new every time
  txb.setTxTime(1460720205)
  return txb
}
////////////////////////////////
console.log("start Session")
// does not have a change address!!!
var mytxval =  {
        "description": "Transaction w/ pubKeyHash -> pubKeyHash",
        "network": "peercoin",
        "txHex": "010000004dd2105701218496ee633f4ef4868805bbfc96109cd9fbc4d61497787fbb70df618d04a6bb010000006a47304402205b0ca994f998c888f1fc41099833e9ca0c1e8850d701c3d694490f535dc6189002201239ad538887d11a3ab70681498c786b2fff910b9e7829c495622f162667ee200121035664d77753a914dff49fc6d5be50bd69e3f9385bbaa9d7229c0f6d3bebaab7abffffffff0110270000000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000",
        "inputs": [
          {
            "txId": "bba6048d61df70bb7f789714d6c4fbd99c1096fcbb058886f44e3f63ee968421",
            "vout": 1,
            "signs": [
              {
                "keyPair": "UDUbFUCAPJiTsZFsSYYGyGMjWG6qUG4eupoggjp5qTf4YTKwY9TU"
              }
            ]
          }
        ],
        "outputs": [
          {
            "script": "OP_DUP OP_HASH160 fa2a8018355c004a9493f5df5fe3dd399f382997 OP_EQUALVERIFY OP_CHECKSIG",
            "value": 10000
          }
        ]
      };
 
 var txb = construct(mytxval)
 var tx = txb.build()
 var test1=tx.toHex();
        
console.log("Session: %j", test1);

if (test1!=mytxval.txHex) console.log("tx not equal");

I have not yet done sendrawtransaction 010000004dd2105701218496ee633f4ef4868805bbfc96109cd9fbc4d61497787fbb70df618d04a6bb010000006a47304402205b0ca994f998c888f1fc41099833e9ca0c1e8850d701c3d694490f535dc6189002201239ad538887d11a3ab70681498c786b2fff910b9e7829c495622f162667ee200121035664d77753a914dff49fc6d5be50bd69e3f9385bbaa9d7229c0f6d3bebaab7abffffffff0110270000000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000

as I am waiting for 6 conformations but I dont see why this should not work.

At this point I strongly suggest to switch to testnet as the conformation time is only 1 minute i believe… The values for testnet can be found here https://wiki.peercointalk.org/index.php?title=Peercoin_developer_notes[/quote]

I’ve just try to send your transaction but i have same error: “ERROR: ConnectInputs() : 02fa4bcd9f VerifySignature failed”

I think I made an mistake. I should have set the txtime before I sign:

var txb = new TransactionBuilder(network);
txb.setTxTime(1460731857);

the tx hex becomes:
01000000d1ff105701218496ee633f4ef4868805bbfc96109cd9fbc4d61497787fbb70df618d04a6bb010000006b483045022100f1d3c45e9e3a81302ac58cb866d30ed7b13f72a73373cbfe314fbe5e4da67b0e0220611d7e9ccc9b6962ebce7a37580aaf22c348a2113743bf361323c0d7a4f16ca90121035664d77753a914dff49fc6d5be50bd69e3f9385bbaa9d7229c0f6d3bebaab7abffffffff0110270000000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000

An other mistake: “vout” should be 0, not 1.
It has only one output.

The error:

ERROR: FetchInputs() : d431b989a7 prevout.n out of range 1 1 1 prev tx bba6048d61 CTransaction(hash=bba6048d61, nTime=1460725009, ver=1, vin.size=1, vout.size=1, nLockTime=0) CTxIn(COutPoint(ac8c241170, 1), scriptSig=304502201a512e7e23aded13) CTxOut(nValue=0.02, scriptPubKey=OP_DUP OP_HASH160 89f236a608a46f1b406df76a3deb3339d84c0501 OP_EQUALVERIFY OP_CHECKSIG)

yeah thx. Figured it out with https://ppc.blockr.io/api/v1/tx/info/d45d8db257d1a9f5c7448c916e8d53aada5ede41328ddc5e55678e7cbb01c554

I ve finally made it work: https://ppc.blockr.io/tx/info/94c7bd3bb5abc49457229ad54da9e49352b586692a98e029766f2fcb21472515

;D ;D ;D ;D ;D ;D ;D ;D ;D

with:
sendrawtransaction 01000000222511570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006b483045022100db392158053ecd4abdc3598d44a1629ce4b9f4a1b430a86ff8921714cc1e7172022024b54e372584d577750c2363266451a71db580538654cb79c3c6afed5e13ea32012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000

with the following config:

var mytxval = { "description": "Transaction w/ pubKeyHash -> pubKeyHash", "network": "peercoin", "txHex": "01000000222511570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006b483045022100db392158053ecd4abdc3598d44a1629ce4b9f4a1b430a86ff8921714cc1e7172022024b54e372584d577750c2363266451a71db580538654cb79c3c6afed5e13ea32012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000", "inputs": [ { "txId": "d45d8db257d1a9f5c7448c916e8d53aada5ede41328ddc5e55678e7cbb01c554", "vout": 0, "signs": [ { "keyPair": "UBFEAigHah8pazgQJSZu4EuaabvuMEJofMgcQ4H6gSLregpHZyzH" } ] } ], "outputs": [ { "script": "OP_DUP OP_HASH160 fa2a8018355c004a9493f5df5fe3dd399f382997 OP_EQUALVERIFY OP_CHECKSIG", "value": 280000 } ] };
notice the fee of 0.30-0.28=0.02ppc instead of 0.01 :-*

[quote=“thehuntergames, post:35, topic:3843”]yeah thx. Figured it out with https://ppc.blockr.io/api/v1/tx/info/d45d8db257d1a9f5c7448c916e8d53aada5ede41328ddc5e55678e7cbb01c554

I ve finally made it work: https://ppc.blockr.io/tx/info/94c7bd3bb5abc49457229ad54da9e49352b586692a98e029766f2fcb21472515

;D ;D ;D ;D ;D ;D ;D ;D ;D

with:
sendrawtransaction 01000000222511570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006b483045022100db392158053ecd4abdc3598d44a1629ce4b9f4a1b430a86ff8921714cc1e7172022024b54e372584d577750c2363266451a71db580538654cb79c3c6afed5e13ea32012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000

with the following config:

var mytxval = { "description": "Transaction w/ pubKeyHash -> pubKeyHash", "network": "peercoin", "txHex": "01000000222511570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006b483045022100db392158053ecd4abdc3598d44a1629ce4b9f4a1b430a86ff8921714cc1e7172022024b54e372584d577750c2363266451a71db580538654cb79c3c6afed5e13ea32012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000", "inputs": [ { "txId": "d45d8db257d1a9f5c7448c916e8d53aada5ede41328ddc5e55678e7cbb01c554", "vout": 0, "signs": [ { "keyPair": "UBFEAigHah8pazgQJSZu4EuaabvuMEJofMgcQ4H6gSLregpHZyzH" } ] } ], "outputs": [ { "script": "OP_DUP OP_HASH160 fa2a8018355c004a9493f5df5fe3dd399f382997 OP_EQUALVERIFY OP_CHECKSIG", "value": 280000 } ] };
notice the fee of 0.30-0.28=0.02ppc instead of 0.01 :-*[/quote]

I’ve clone your code and it does not work for me :frowning:

[code]var bscript = require(’…/src/script’)

var ECPair = require(’…/src/ecpair’)
var TransactionBuilder = require(’…/src/transaction_builder’)
var NETWORKS = require(’…/src/networks’)

function construct (f, sign) {
var network = NETWORKS[f.network]
var txb = new TransactionBuilder(network)
txb.setTxTime(1460720205)

// FIXME: add support for version in TransactionBuilder API
if (f.version !== undefined) {
txb.tx.version = f.version
}

if (f.locktime !== undefined) {
txb.setLockTime(f.locktime)
}

f.inputs.forEach(function (input) {
var prevTxScript

if (input.prevTxScript) {
  prevTxScript = bscript.fromASM(input.prevTxScript)
}

txb.addInput(input.txId, input.vout, input.sequence, prevTxScript)

})

f.outputs.forEach(function (output) {
txb.addOutput(bscript.fromASM(output.script), output.value)
})

if (sign === undefined || sign) {
f.inputs.forEach(function (input, index) {
input.signs.forEach(function (sign) {
var keyPair = ECPair.fromWIF(sign.keyPair, network)
var redeemScript

    if (sign.redeemScript) {
      redeemScript = bscript.fromASM(sign.redeemScript)
    }

    txb.sign(index, keyPair, redeemScript, sign.hashType)
  })
})

}
//txb.setTxTime(Math.round((new Date()).getTime() / 1000)); // this is new every time
return txb
}
////////////////////////////////
console.log(“start Session”)
// does not have a change address!!!
var mytxval = {
“description”: “Transaction w/ pubKeyHash -> pubKeyHash”,
“network”: “peercoin”,
“txHex”: “01000000222511570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006b483045022100db392158053ecd4abdc3598d44a1629ce4b9f4a1b430a86ff8921714cc1e7172022024b54e372584d577750c2363266451a71db580538654cb79c3c6afed5e13ea32012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000”,
“inputs”: [
{
“txId”: “d45d8db257d1a9f5c7448c916e8d53aada5ede41328ddc5e55678e7cbb01c554”,
“vout”: 0,
“signs”: [
{
“keyPair”: “UBFEAigHah8pazgQJSZu4EuaabvuMEJofMgcQ4H6gSLregpHZyzH”
}
]
}
],
“outputs”: [
{
“script”: “OP_DUP OP_HASH160 fa2a8018355c004a9493f5df5fe3dd399f382997 OP_EQUALVERIFY OP_CHECKSIG”,
“value”: 280000
}
]
};
var txb = construct(mytxval)
var tx = txb.build()
var test1=tx.toHex();

console.log(“Session: %j”, test1);

if (test1!=mytxval.txHex) console.log(“tx not equal”);[/code]

result:

start Session Session: "010000004dd210570154c501bb7c8e67555edc8d3241de5edaaa538d6e918c44c7f5a9d157b28d5dd4000000006a47304402207c4c479cd0eb0f4c3bdff1700b0b7e4ebb6a9fe5b6bd805883133358e659e43102203e24f7249c2bba04f81dd5820ec3f31895e66a1c3fc50ed65dc7908b65e462cf012102aba03213ddea571140034d40f81639aaf414d7874acb886e88fdf5c195acfa40ffffffff01c0450400000000001976a914fa2a8018355c004a9493f5df5fe3dd399f38299788ac00000000" tx not equal

EDIT
I found my error here!

txb.setTxTime(1460741410)

It is working now! Thank you!

Hi [member=32923]kzv[/member]

What are your further plans with the multicoins client?
We really like to have you active in our community, to make your client a recommended one.

Are you planning to work on the styling (something like https://www.myetherwallet.com/) ?
Are you open to contributions? As there are some features that I’d like to see added.

I have one technical question: if you make a transaction, which address do you use as the change address?

[quote=“hrobeers, post:37, topic:3843”]Hi [member=32923]kzv[/member]

What are your further plans with the multicoins client?
We really like to have you active in our community, to make your client a recommended one.

Are you planning to work on the styling (something like https://www.myetherwallet.com/) ?
Are you open to contributions? As there are some features that I’d like to see added.

I have one technical question: if you make a transaction, which address do you use as the change address?[/quote]

Hi [member=32827]hrobeers[/member]

What are your further plans with the multicoins client?
I myself always use this service. If I see an error or I see that something features is missing then i fix bugs and/or add new features.
Are you planning to work on the styling (something like https://www.myetherwallet.com/) ?
Maybe yes. I do not know... I have never used this service.
Are you open to contributions? As there are some features that I'd like to see added.
Of course! I have added license file: https://github.com/3s3s/multicoins.org/blob/master/LICENSE
I have one technical question: if you make a transaction, which address do you use as the change address?
taken the first unspent address in the wallet https://github.com/3s3s/multicoins.org/blob/master/server_side/sendTransaction.js#L169

I have used myetherwallet for one occasion around its peak.
The neat thing about it was I could download the code from github and run it locally. Everything still worked.
So cross-domain javascript POST & GET were supported, I suppose.
Certainly worth a look at besides the look and feel of this wallet.

I also just used it to get rid of my ether with a nice gain.
I found it after getting frustrated with geth downloading the 13+Gb blockchain.

Myetherwallet definitely is one of the better things about ethereum.