9

Here: var bitcoin = require('bitcoinjs-lib') data = new Buffer("Melons.") var tx = new bitcoin.TransactionBuilder() tx.addInput("aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31", 0) tx.addOutput("some address", 15000) ret = bitcoin.script.compile( [ bitcoin.opcodes.OP_RETURN, data ]) tx.addOutput(ret, 0) key = bitcoin.ECPair....


6

If you call bitcoin.address.toOutputScript(address, bitcoin.networks.bitcoin) It will throw an error if the address cannot be parsed as P2SH or P2PKH, or if the checksum is not valid. Replace the second argument with bitcoin.networks.testnet for testnet.


5

You need to run your bitcoinjs-server exit with --testnet. bitcoinjs run --testnet Source Are there any existing public bitcoinjs exits running in testnet mode? I don't know.


4

So if I were to create the same transaction using bitcoinjs and bitcoinj, the end result of the signed transaction would be the same with both libraries, is that correct? They certainly should. That's why they're called deterministic. Any particular library could have a bug in it, however. I would check against examples given in the spec to make sure a ...


4

Use Electrum 3.1.1 and prepend "p2wpkh:" to the private key before importing or sweeping it. For example: p2wpkh:5Kkzs8XrJNAmf9VQDFeGBfaRvSByAvPK6DbDXw5BVqswWaXSG2Y


3

In bitcoin-js you could do something like this aliceToBobRedeemScript = bitcoin.script.compile([, bitcoin.opcodes.OP_IF, bitcoin.opcodes.OP_HASH160, aliceSecretHash, bitcoin.opcodes.OP_EQUALVERIFY, bobPrivKey.getPublicKeyBuffer(), bitcoin.opcodes.OP_ELSE, bitcoin.script.number.encode(10), bitcoin.opcodes.OP_NOP3, bitcoin.opcodes.OP_DROP, ...


3

Oops! Noob mistake. I thought that testnet and regtest had different version prefixes (not compatible) but they are (the bitcoin wiki and bitcoin developers page doesn't clarify this, though). So I went into a npm package that added dogecoin and litecoin testnets compatibility with bitcoinjs-lib (it's called bitcoinjs-testnets). But the solution in the ...


3

According the to the status message at the bottom of the page: https://github.com/bitcoinjs/node-bitcoin-exit First permanent deployment is online at https://exit.trucoin.com:3125/


2

I think my issue was that I was accidentally trying to spend the output from my first transaction (which had insufficient funds for both the given fee and the given amount of change) instead of the output I was getting from the faucet, which I meant to spend. I haven't written a good solution to this problem yet, but I got around it in this simplified ...


2

You should not use an online service for broadcasting transaction. This online-service would have full control (censor?) over your transaction. The service could analyze your data behavior and/or decide to not broadcast your transaction regarding some rules. Wladimir van der Laan (current bitcoin-core project maintainer) has written a neat tool: https://...


2

So... I found out what was wrong. The problem was in this part of the code when i was adding the inputs. I was adding an index to each input based on which number of input it was. for(var a = 0; a < input_utxos.length ; a++){ tx.addInput(input_utxos[a].tx,a) sum_outputs+=parseInt(input_utxos[a].amount); } but the index i was supossed to send ...


2

That particular line of code asserts that the private key fits into a 32 byte-sized byte array properly with the necessary zero paddings. As the private key is simply some random Big Integer between 0 ~ 2^(256-1), javascript may encode that integer into different byte array sizes. For example, if the d value was simply 1, then it could easily fit into a 1 ...


2

The fee is the sum of unspent value in a Transaction. Aka the value NOT SENT by your outputs. fee = in - out For an example, if we assume the input aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31, 0 has an unspent value of 15000... var txb = new bitcoin.TransactionBuilder() txb.addInput('...


2

Body must be a string. You can use form instead of body. Reference: https://www.npmjs.com/package/request#forms


2

A Trezor signed message with a 3 address can be verified here: https://jhoenicke.github.io/brainwallet.github.io/#verify Or your can verify it with another Trezor wallet.


2

The short answer is: you probably shouldn't. That is not a typical way to generate an xpriv/xpub. You are trying to convert a key pair to an extended key pair. The difference is the extended keys include the following (See BIP32 - Serialization Format): 4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: 0x043587CF public, ...


1

This code calls this code, which calls crypto.getRandomValues, which is a trustworthy cryptographically secure random number generator. It's secure enough to compete with bitaddress.org, as long as one's browser was not hacked.


1

following the link https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki: 1.) the timeDelay in your example represents two possibilities: // There are two kinds of nSequence: lock-by-blockheight // and lock-by-blocktime, distinguished by whether // nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG. 2.) when I get this correctly, it is BIP68 ...


1

I'm doing something similar but using segwit addresses (BIP49). If you are using BIP32 with a standard derivation of m/0'/0/0 you could do something like this - See: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js#L35 //get a mnemonic, then seed, then root. var mnemonic = bip39.generateMnemonic(); var seed = bip39....


1

Got the answer via github let script = bitcoin.address.toOutputScript(address) let hash = bitcoin.crypto.sha256(script) let reversedHash = new Buffer(hash.reverse()) console.log(address, ' maps to ', reversedHash.toString('hex')) Note that -for some reason- Electrum uses the reverse scripthash


1

You will, by default, only see the values of the outputs and not the inputs. To gather all values for inputs, you will need to loop through your inputs and use an API to gather the transactions where the inputs were once outputs. I used the BitPay insight API and left some notes in the code below: var Bitcoin = require('bitcoinjs-lib'); var request = ...


1

How should I process this data so I can get total in and out amounts and calculate transaction fee? Each in contains a (hash, index) to a previous output in the blockchain. Assuming you have a full node with txindex=1 meaning there's a full index of all previous transactions. You can use (hash, index) to find the original UTXO that carries the actual value. ...


1

BitcoinJS does not link directly to the bitcoin network, it is simply a collection of bitcoin-related functions. Taking your example above, if we wanted to create a transaction with BitcoinJS' transaction builder function, we would have to find the inputs ourselves via API's (or asking your own full node if you have one) and add then it with tx.addInput(...


1

See Blockchain.info wallet source code https://github.com/blockchain/My-Wallet-V3 Also check the bitcoinjs-lib's list of projects


1

Wallet Import Format can be used in a Javascript String, which is JSON compatible. For bitcoinjs-lib@^2.0.0: var prv = keyPair.toWIF() To recover, use bitcoin.ECPair.fromWIF(prv) Caution: if you store your private key in an insecure location, your funds will be insecure. fromWIF/toWIF does not provide any form of protection.


1

There are a lot of different projects that are looking to solve this problem. Almost all of them use something like colored coins to track an asset on the blockchain. Essentially, what your plan is missing are clear rules that prevent double spending. Check out coinprism.com, colu.co and chromawallet.com for just a few different implementations of what you'...


1

API selection with other technology selection is having major dependencies on final goal. so you have to select the best suit of technology as per the business requirement.


1

I found what I was looking for. Blockr.io has a good service for publishing transactions to the network. This is the url that you would send a post request to http://btc.blockr.io/api/v1/tx/push Make sure to send it the transaction as a post request like this: {"hex" : your transaction in hex}


1

Most of the libraries you mentioned would work for this problem. However, some are built more like libraries to be called from other javascript (eg. BitcoinJS), while others are designed with a full user interface so a semi-technical user can host multisig signing functionality on their browser (eg Copay). Some options you mentioned are also multisig wallet ...


1

You should try using BIP32 to generate addresses. There's a node.js implementation here: http://cryptocoinjs.com/modules/currency/hdkey/


Only top voted, non community-wiki answers of a minimum length are eligible