Skip to content

DogeCoin TransactionBuilder example? #855

@ghost

Description

Can anyone give me an example how to create and sign DogeCoin transaction please? I tried something like this:

var bitcoin = require('bitcoinjs-lib');
var coininfo = require('coininfo');
var doge_network = coininfo.dogecoin.main.toBitcoinJS();

var tx = new bitcoin.TransactionBuilder(doge_network)

// Add the input (who is paying):
// [previous transaction hash, index of the output to use]
var txId = 'ac3e9372e66281bf57b2146b90ede4223e15bb5575dae0e74ce0c55fa9cf7b7d'
tx.addInput(txId, 0)

// Add the output (who to pay to):
// [payee's address, amount in satoshis]
tx.addOutput("DG5xxVMn6jRLqoX3KiQAdMAHGy5GJhG8YU", 1000000000)

// Initialize a private key using WIF
var privateKeyWIF = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF, doge_network)

// Sign the first input with the new key
tx.sign(0, keyPair)

// Print transaction serialized as hex
console.log(tx.build().toHex())
// => 0100000001313eb630b128102b60241ca895f1d0ffca21 ...

// You could now push the transaction onto the Bitcoin network manually
// (see https://blockchain.info/pushtx)

but I got:

        throw tfSubError(e, propertyName)
        ^
Error
    at new TfTypeError (C:\Users\s718\node_modules\typeforce\errors.js:5:24)
    at typeforce (C:\Users\s718\node_modules\typeforce\index.js:193:11)
    at _object (C:\Users\s718\node_modules\typeforce\index.js:99:11)
    at _maybe (C:\Users\s718\node_modules\typeforce\index.js:35:35)
    at typeforce (C:\Users\s718\node_modules\typeforce\index.js:191:9)
    at _object (C:\Users\s718\node_modules\typeforce\index.js:99:11)
    at typeforce (C:\Users\s718\node_modules\typeforce\index.js:191:9)
    at typeforce (C:\Users\s718\node_modules\typeforce\index.js:197:10)
    at new ECPair (C:\Users\s718\node_modules\bitcoinjs-lib\src\ecpair.js:17:5)
    at Function.ECPair.fromWIF (C:\Users\s718\node_modules\bitcoinjs-lib\src\ecpair.js:81:10)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions