btcpayserver: PayJoin *client* randomly fails with bogus error "Some of our outputs are not included in the proposal"

Describe the bug When testing loptos with BTCPayServer wallet as the client it occasionally reports correctly-looking (see log below) PSBT as missing outputs.

To Reproduce the bug Steps to reproduce the reported bug:

  1. Deploy regtest setup with a version of lnd created by merging https://github.com/lightningnetwork/lnd/pull/5363
  2. Deploy loptos
  3. Create a store with hot wallet
  4. Send 1 regtest BTC to BTCPay internal wallet
  5. Spawn a secondary node
  6. Connect from LND to secondary node
  7. Launch loptos - attempt to open 1M channel
  8. Copy BIP21 from output of loptos and paste it in BTCPay wallet “Send” tab
  9. Broadcast transaction
  10. If it succeeded, mine 7 blocks and repeat steps starting from 5
  11. If BTCPay failed with above-mentioned message observe debug output

Expected behavior

PayJoin succeeds every time (or fails for reason unrelated to BTCPayServer)

Your BTCPay Environment (please complete the following information):

  • BTCPay Server Version: 1.1.2
  • Deployment Method: Debian package
  • Browser: Firefox ESR (irrelevant)

Logs (if applicable)

Nothing interesting in BTCPay log.

Log from loptos
[src/main.rs:56] req.uri().query() = Some(
    "v=1&additionalfeeoutputindex=1&maxadditionalfeecontribution=6800",
)
Received transaction: PartiallySignedTransaction {
    global: Global {
        unsigned_tx: Transaction {
            version: 2,
            lock_time: 0,
            input: [
                TxIn {
                    previous_output: OutPoint {
                        txid: 5108f7639e6d141b2c2520c58e73fb2aa278a512965a7921bcfd2f8c1f0a81ee,
                        vout: 0,
                    },
                    script_sig: Script(),
                    sequence: 4294967295,
                    witness: [],
                },
            ],
            output: [
                TxOut {
                    value: 1000000,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 6dbfaed20d0eb3091ada404ac829f5266e55c01b),
                },
                TxOut {
                    value: 95943600,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 b271f99690c5c011f62f124d92a9f126cccee3d8),
                },
            ],
        },
        version: 0,
        xpub: {},
        proprietary: {},
        unknown: {},
    },
    inputs: [
        Input {
            non_witness_utxo: None,
            witness_utxo: Some(
                TxOut {
                    value: 96957700,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 111ea18add90174f4b5d5e534ba1b6683e8b04f0),
                },
            ),
            partial_sigs: {},
            sighash_type: None,
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            final_script_sig: None,
            final_script_witness: Some(
                [
                    [
                        48,
                        68,
                        2,
                        32,
                        94,
                        131,
                        215,
                        30,
                        29,
                        225,
                        153,
                        242,
                        18,
                        52,
                        132,
                        114,
                        224,
                        96,
                        98,
                        229,
                        236,
                        103,
                        66,
                        207,
                        12,
                        56,
                        163,
                        54,
                        120,
                        132,
                        84,
                        63,
                        180,
                        193,
                        119,
                        224,
                        2,
                        32,
                        27,
                        188,
                        120,
                        192,
                        109,
                        26,
                        117,
                        144,
                        89,
                        228,
                        78,
                        69,
                        3,
                        41,
                        236,
                        35,
                        52,
                        33,
                        46,
                        215,
                        31,
                        250,
                        213,
                        217,
                        156,
                        33,
                        125,
                        39,
                        36,
                        37,
                        37,
                        83,
                        1,
                    ],
                    [
                        3,
                        196,
                        202,
                        61,
                        183,
                        121,
                        82,
                        47,
                        63,
                        217,
                        149,
                        156,
                        141,
                        64,
                        52,
                        243,
                        240,
                        144,
                        66,
                        33,
                        207,
                        111,
                        68,
                        13,
                        132,
                        76,
                        214,
                        236,
                        253,
                        101,
                        5,
                        92,
                        148,
                    ],
                ],
            ),
            ripemd160_preimages: {},
            sha256_preimages: {},
            hash160_preimages: {},
            hash256_preimages: {},
            proprietary: {},
            unknown: {},
        },
    ],
    outputs: [
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
    ],
}
After removing our output: PartiallySignedTransaction {
    global: Global {
        unsigned_tx: Transaction {
            version: 2,
            lock_time: 0,
            input: [
                TxIn {
                    previous_output: OutPoint {
                        txid: 5108f7639e6d141b2c2520c58e73fb2aa278a512965a7921bcfd2f8c1f0a81ee,
                        vout: 0,
                    },
                    script_sig: Script(),
                    sequence: 4294967295,
                    witness: [],
                },
            ],
            output: [
                TxOut {
                    value: 95943600,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 b271f99690c5c011f62f124d92a9f126cccee3d8),
                },
            ],
        },
        version: 0,
        xpub: {},
        proprietary: {},
        unknown: {},
    },
    inputs: [
        Input {
            non_witness_utxo: None,
            witness_utxo: Some(
                TxOut {
                    value: 96957700,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 111ea18add90174f4b5d5e534ba1b6683e8b04f0),
                },
            ),
            partial_sigs: {},
            sighash_type: None,
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            final_script_sig: None,
            final_script_witness: Some(
                [
                    [
                        48,
                        68,
                        2,
                        32,
                        94,
                        131,
                        215,
                        30,
                        29,
                        225,
                        153,
                        242,
                        18,
                        52,
                        132,
                        114,
                        224,
                        96,
                        98,
                        229,
                        236,
                        103,
                        66,
                        207,
                        12,
                        56,
                        163,
                        54,
                        120,
                        132,
                        84,
                        63,
                        180,
                        193,
                        119,
                        224,
                        2,
                        32,
                        27,
                        188,
                        120,
                        192,
                        109,
                        26,
                        117,
                        144,
                        89,
                        228,
                        78,
                        69,
                        3,
                        41,
                        236,
                        35,
                        52,
                        33,
                        46,
                        215,
                        31,
                        250,
                        213,
                        217,
                        156,
                        33,
                        125,
                        39,
                        36,
                        37,
                        37,
                        83,
                        1,
                    ],
                    [
                        3,
                        196,
                        202,
                        61,
                        183,
                        121,
                        82,
                        47,
                        63,
                        217,
                        149,
                        156,
                        141,
                        64,
                        52,
                        243,
                        240,
                        144,
                        66,
                        33,
                        207,
                        111,
                        68,
                        13,
                        132,
                        76,
                        214,
                        236,
                        253,
                        101,
                        5,
                        92,
                        148,
                    ],
                ],
            ),
            ripemd160_preimages: {},
            sha256_preimages: {},
            hash160_preimages: {},
            hash256_preimages: {},
            proprietary: {},
            unknown: {},
        },
    ],
    outputs: [
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
    ],
}
PSBT received from LND: PartiallySignedTransaction {
    global: Global {
        unsigned_tx: Transaction {
            version: 2,
            lock_time: 0,
            input: [],
            output: [
                TxOut {
                    value: 1000000,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_32 2f550284b82d23461e055a1faeec23a9efed25e7986da3a09784dd07a6a19775),
                },
            ],
        },
        version: 0,
        xpub: {},
        proprietary: {},
        unknown: {},
    },
    inputs: [],
    outputs: [
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
    ],
}
PSBT to be given to LND: PartiallySignedTransaction {
    global: Global {
        unsigned_tx: Transaction {
            version: 2,
            lock_time: 0,
            input: [
                TxIn {
                    previous_output: OutPoint {
                        txid: 5108f7639e6d141b2c2520c58e73fb2aa278a512965a7921bcfd2f8c1f0a81ee,
                        vout: 0,
                    },
                    script_sig: Script(),
                    sequence: 4294967295,
                    witness: [],
                },
            ],
            output: [
                TxOut {
                    value: 95943600,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 b271f99690c5c011f62f124d92a9f126cccee3d8),
                },
                TxOut {
                    value: 1000000,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_32 2f550284b82d23461e055a1faeec23a9efed25e7986da3a09784dd07a6a19775),
                },
            ],
        },
        version: 0,
        xpub: {},
        proprietary: {},
        unknown: {},
    },
    inputs: [
        Input {
            non_witness_utxo: None,
            witness_utxo: Some(
                TxOut {
                    value: 96957700,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 111ea18add90174f4b5d5e534ba1b6683e8b04f0),
                },
            ),
            partial_sigs: {},
            sighash_type: None,
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            final_script_sig: None,
            final_script_witness: Some(
                [
                    [
                        48,
                        68,
                        2,
                        32,
                        94,
                        131,
                        215,
                        30,
                        29,
                        225,
                        153,
                        242,
                        18,
                        52,
                        132,
                        114,
                        224,
                        96,
                        98,
                        229,
                        236,
                        103,
                        66,
                        207,
                        12,
                        56,
                        163,
                        54,
                        120,
                        132,
                        84,
                        63,
                        180,
                        193,
                        119,
                        224,
                        2,
                        32,
                        27,
                        188,
                        120,
                        192,
                        109,
                        26,
                        117,
                        144,
                        89,
                        228,
                        78,
                        69,
                        3,
                        41,
                        236,
                        35,
                        52,
                        33,
                        46,
                        215,
                        31,
                        250,
                        213,
                        217,
                        156,
                        33,
                        125,
                        39,
                        36,
                        37,
                        37,
                        83,
                        1,
                    ],
                    [
                        3,
                        196,
                        202,
                        61,
                        183,
                        121,
                        82,
                        47,
                        63,
                        217,
                        149,
                        156,
                        141,
                        64,
                        52,
                        243,
                        240,
                        144,
                        66,
                        33,
                        207,
                        111,
                        68,
                        13,
                        132,
                        76,
                        214,
                        236,
                        253,
                        101,
                        5,
                        92,
                        148,
                    ],
                ],
            ),
            ripemd160_preimages: {},
            sha256_preimages: {},
            hash160_preimages: {},
            hash256_preimages: {},
            proprietary: {},
            unknown: {},
        },
    ],
    outputs: [
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
    ],
}
PSBT that will be returned: PartiallySignedTransaction {
    global: Global {
        unsigned_tx: Transaction {
            version: 2,
            lock_time: 0,
            input: [
                TxIn {
                    previous_output: OutPoint {
                        txid: 5108f7639e6d141b2c2520c58e73fb2aa278a512965a7921bcfd2f8c1f0a81ee,
                        vout: 0,
                    },
                    script_sig: Script(),
                    sequence: 4294967295,
                    witness: [],
                },
            ],
            output: [
                TxOut {
                    value: 95943600,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_20 b271f99690c5c011f62f124d92a9f126cccee3d8),
                },
                TxOut {
                    value: 1000000,
                    script_pubkey: Script(OP_0 OP_PUSHBYTES_32 2f550284b82d23461e055a1faeec23a9efed25e7986da3a09784dd07a6a19775),
                },
            ],
        },
        version: 0,
        xpub: {},
        proprietary: {},
        unknown: {},
    },
    inputs: [
        Input {
            non_witness_utxo: None,
            witness_utxo: None,
            partial_sigs: {},
            sighash_type: None,
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            final_script_sig: None,
            final_script_witness: None,
            ripemd160_preimages: {},
            sha256_preimages: {},
            hash160_preimages: {},
            hash256_preimages: {},
            proprietary: {},
            unknown: {},
        },
    ],
    outputs: [
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
        Output {
            redeem_script: None,
            witness_script: None,
            bip32_derivation: {},
            proprietary: {},
            unknown: {},
        },
    ],
}

Additional context

I attempted to check the logic first to see why it reports removed output despite the output being there but couldn’t find the code handling it in BTCPayServer repository.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Thank you for quick release!

Sorry @Kixunil for taking time about this one, forgot about it. I’ll dig into it for next small release.