I'm trying to build a nodejs command with commander, bitcoinjs-lib, bitcoincashjs, blocktrail-sdk. Currently I got the problem when trying to spend the Bitcoin Cash of segwit address.


  • A is BTC segwit address
  • B, C is Bitcoin Cash address
  • B send Bitcoin Cash to A

=> How to send Bitcoin Cash of A to C?

I've tried with this code but failed.

bch.Networks.defaultNetwork = bch.Networks.testnet;

var toAddress = "xxxx";

var blocktrail_client = blocktrail.BlocktrailSDK({
    apiKey: "xxxx",
    apiSecret: "xxxx",
    network: "BCC",
    testnet: true

var privKey = "xxxx";
var privateKey = new bch.PrivateKey(privKey);
var address = privateKey.toAddress().toString();

    .then(async (res, error) => {
        if (error) {
            return console.log(error);
        if (res.data.length == 0) {
            return console.log("Error. Nothing to send.")

    var tx = res.data[0];

    utxo = {
        txId: tx.hash,
        outputIndex: 0,
        script: tx.script_hex,
        satoshis: tx.value

    const transaction = new bch.Transaction()
        .to(toAddress, tx.value - 1000)

        (error, hash) => {
            if (error) {
                return console.log(error);
            return console.log(hash);
.catch(error => console.log(error));
  • 1
    you do not need to sign this transaction – amaclin Mar 30 '18 at 9:48
  • @amaclin thank you for your comment, would you please help me explain more details? – Tho Nguyen Mar 30 '18 at 10:06
  • This makes no sense. You can't send BCH to a BTC address; it's a different network, different blockchain, and different currency. You can't send USD to a BTC address either. You'll need to find an exchange or someone willing to trade. Also, segwit does not exist on the BCH chain. – Pieter Wuille Mar 31 '18 at 18:09
  • 1
    @PieterWuille: Actually, Bitcoin addresses are valid on the Bitcoin Cash network, so you can send BCH to an address that is part of a Bitcoin wallet. This has been a major headache to wallet provider services. Most cases are fairly easy to fix, but recovering funds sent to a segwit address is more complicated. – Murch Nov 27 '18 at 17:19