Skip to content

chain: add SubmitPackage API for atomic parents+child relay #1009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bhandras
Copy link
Contributor

@bhandras bhandras commented May 5, 2025

Change Description

This commit introduces first-class support for Bitcoin Core's submitpackage RPC (v26+), allowing btcwallet users to broadcast (potentially zero‑fee) parent txns together with their (fee‑paying) child txn in one call.

Depends on: btcsuite/btcd#2366

Steps to Test

N/A

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@bhandras bhandras changed the title chain: add SubmitPackage API for atomic parent+children relay chain: add SubmitPackage API for atomic parents+child relay May 5, 2025
@bhandras bhandras marked this pull request as ready for review May 5, 2025 20:04

submittedIDs := make([]*chainhash.Hash, 0, len(result.TxResults))
for _, txRes := range result.TxResults {
if txRes.Error != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't skip on Error. There is also a 'PackageMessage' field in btcjson.SubmitPackageResult which we could use, this can be "success" or "transaction failed" (maybe more). I think if "transaction failed" we'd want to get the error message of each tx. See:

SubmitPackage response: (btcjson.SubmitPackageResult) {
         PackageMsg: (string) (len=18) "transaction failed",
         TxResults: (map[string]btcjson.SubmitPackageTxResult) (len=2) {
          (string) (len=64) "a1946b6a4318e4cf598778d74dd4377a0417294473b2223751e7cc4ba52e93ec": (btcjson.SubmitPackageTxResult) {
           TxID: (string) (len=64) "b46359e30f5b8f5a5a961fedd225b44e264687f8a21c204a7cfd8ee0e305ee3e",
           OtherWtxid: (*string)(<nil>),
           VSize: (int64) 0,
           Fees: (btcjson.SubmitPackageFees) {
            Base: (float64) 0,
            EffectiveFeeRate: (*float64)(<nil>),
            EffectiveIncludes: ([]string) <nil>
           },
           Error: (*string)(0xc00128d580)((len=30) "bad-txns-inputs-missingorspent")
          },
          (string) (len=64) "4e080b762bc75de2e48b40b43eb36bd36b6faaa72bb99a3ae03b0b2f7e66629a": (btcjson.SubmitPackageTxResult) {
           TxID: (string) (len=64) "9bc86f989b423e4189413fcbbda4c7820edca5fcce4a8078333d4a91fecb5d48",
           OtherWtxid: (*string)(<nil>),
           VSize: (int64) 0,
           Fees: (btcjson.SubmitPackageFees) {
            Base: (float64) 0,
            EffectiveFeeRate: (*float64)(<nil>),
            EffectiveIncludes: ([]string) <nil>
           },
           Error: (*string)(0xc00128d5a0)((len=30) "bad-txns-inputs-missingorspent")
          }
         },
         ReplacedTransactions: ([]string) {
         }
        }

success:

 lnd_wallet.go:379: SubmitPackage response: (btcjson.SubmitPackageResult) {
         PackageMsg: (string) (len=7) "success",
         TxResults: (map[string]btcjson.SubmitPackageTxResult) (len=2) {
          (string) (len=64) "00063b73b1b564833e552e70ce3ce1ff2d6c101d5c44d0acc755c9553ff0be4b": (btcjson.SubmitPackageTxResult) {
           TxID: (string) (len=64) "4facdd76aa1d4dbc6e0324b0df4eb398b261a51649831db43b20bc266270cafb",
           OtherWtxid: (*string)(<nil>),
           VSize: (int64) 110,
           Fees: (btcjson.SubmitPackageFees) {
            Base: (float64) 0,
            EffectiveFeeRate: (*float64)(0xc000d42e00)(0),
            EffectiveIncludes: ([]string) (len=1 cap=1) {
             (string) (len=64) "00063b73b1b564833e552e70ce3ce1ff2d6c101d5c44d0acc755c9553ff0be4b"
            }
           },
           Error: (*string)(<nil>)
          },
          (string) (len=64) "0dfbd5cf4dd7f280afa79c3bcb2b919876eec1237273f65ad6761a61d5e88f20": (btcjson.SubmitPackageTxResult) {
           TxID: (string) (len=64) "4091d93ab8e0ef79d646c930bd0a4a8cb103b243b3f1b5b31143e33f8daa171e",
           OtherWtxid: (*string)(<nil>),
           VSize: (int64) 110,
           Fees: (btcjson.SubmitPackageFees) {
            Base: (float64) 1.097e-05,
            EffectiveFeeRate: (*float64)(0xc000d42e08)(9.972e-05),
            EffectiveIncludes: ([]string) (len=1 cap=1) {
             (string) (len=64) "0dfbd5cf4dd7f280afa79c3bcb2b919876eec1237273f65ad6761a61d5e88f20"
            }
           },
           Error: (*string)(<nil>)
          }
         },
         ReplacedTransactions: ([]string) {
         }
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with you, the initial implementation was created more for quickly testing the feature, but now added a higher level result type to btcjson so we get back more data. PTAL.

This commit introduces first-class support for Bitcoin Core's
`submitpackage` RPC (v26+), allowing btcwallet users to broadcast
(potentially zero‑fee) unconfirmed parent txns together with its
(fee‑paying) child in one call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants