Skip to content

Commit b774837

Browse files
f321xSomberNight
authored andcommitted
add submitpackage methods
1 parent 8e26c35 commit b774837

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

docs/protocol-changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,8 @@ Changes
202202
* Optional *mode* argument added to :func:`blockchain.estimatefee`.
203203
* :func:`blockchain.block.headers` now returns headers as a list,
204204
instead of a single concatenated hex string.
205+
206+
New methods
207+
-----------
208+
209+
* :func:`blockchain.transaction.broadcast_package` to broadcast a package of transactions (submitpackage).

docs/protocol-methods.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,92 @@ Protocol version 1.0 returning an error as the result:
569569

570570
"258: txn-mempool-conflict"
571571

572+
blockchain.transaction.broadcast_package
573+
========================================
574+
575+
Broadcast a package of transactions to the network (submitpackage). The package must consist of a child with its parents,
576+
and none of the parents may depend on one another. The package must be topologically sorted,
577+
with the child being the last element in the array.
578+
579+
**Signature**
580+
581+
.. function:: blockchain.transaction.broadcast_package(raw_txs, verbose=false)
582+
583+
*raw_txs*
584+
585+
An array of raw transactions, each as a hexadecimal string.
586+
587+
*verbose*
588+
589+
Whether a verbose coin-specific response is required.
590+
591+
**Result**
592+
593+
If *verbose* is :const:`false`:
594+
595+
A dictionary with the following keys:
596+
597+
* `success`
598+
* Type: bool
599+
* Value: Indicating the result of the package submission
600+
* `errors`
601+
* Type: Optional[List[Dict]]
602+
* Value: Error message and txid (NOT wtxid) of transactions that were not accepted
603+
604+
If *verbose* is :const:`true`:
605+
606+
The bitcoind response according to its RPC API documentation.
607+
Note that the exact structure and semantics can depend on the bitcoind version,
608+
and hence the electrum protocol can make no guarantees about it.
609+
610+
**Result Example**
611+
612+
When *verbose* is :const:`false`::
613+
614+
{
615+
"success": true
616+
}
617+
618+
With errors:
619+
620+
{
621+
"success": false,
622+
"errors":
623+
[
624+
{
625+
"txid": "ec6f295cd4b1b91f59cabb0ab8fdc7c76580db08be6426e465f75a69d82b9659",
626+
"error": "bad-txns-inputs-missingorspent"
627+
}
628+
]
629+
}
630+
631+
When *verbose* is :const:`true`::
632+
633+
{ (json object)
634+
"package_msg" : "str", (string) The transaction package result message. "success" indicates all transactions were accepted into or are already in the mempool.
635+
"tx-results" : { (json object) transaction results keyed by wtxid
636+
"wtxid" : { (json object) transaction wtxid
637+
"txid" : "hex", (string) The transaction hash in hex
638+
"other-wtxid" : "hex", (string, optional) The wtxid of a different transaction with the same txid but different witness found in the mempool. This means the submitted transaction was ignored.
639+
"vsize" : n, (numeric, optional) Sigops-adjusted virtual transaction size.
640+
"fees" : { (json object, optional) Transaction fees
641+
"base" : n, (numeric) transaction fee in BTC
642+
"effective-feerate" : n, (numeric, optional) if the transaction was not already in the mempool, the effective feerate in BTC per KvB. For example, the package feerate and/or feerate with modified fees from prioritisetransaction.
643+
"effective-includes" : [ (json array, optional) if effective-feerate is provided, the wtxids of the transactions whose fees and vsizes are included in effective-feerate.
644+
"hex", (string) transaction wtxid in hex
645+
...
646+
]
647+
},
648+
"error" : "str" (string, optional) The transaction error string, if it was rejected by the mempool
649+
},
650+
...
651+
},
652+
"replaced-transactions" : [ (json array, optional) List of txids of replaced transactions
653+
"hex", (string) The transaction id
654+
...
655+
]
656+
}
657+
572658
blockchain.transaction.get
573659
==========================
574660

0 commit comments

Comments
 (0)