Skip to content

Feature: txmodifypayee a txprepared transaction #3415

@ZmnSCPxj

Description

@ZmnSCPxj

While studying the existing fundchannel in preparation for fully implementing #1936 , I noticed that the current fundchannel does this:

  • connect to peer.
  • txprepare a "dry-run" fundchannel using a dummy funding address.
    • Extract the funding output amount in the returned transaction --- presumably this is how we determine the actual amount when given all.
  • fundchannel_start to peer using the extracted amount, receiving a target funding address
  • txdiscard the previous "dry-run" transaction.
  • txprepare, this time with the now-filled-in funding address.
  • fundchannel_complete with the transaction ID.
  • txsend the transaction.

What I want to point is that in theory, it would be possible for a sufficiently heavily-used server to have some other withdraw, fundchannel, or txprepare execute between the txdiscard of the dry-run transaction and the subsequent txprepare as a multithreaded race condition.

As locking of the RPC is not implemented (and would be dangerous as well --- consider that a plugin can easily deadlock itself with an incorrect lock behavior), we might instead want to have an atomic operation that combines a txdiscard with a txprepare that uses the exact same inputs and outputs, just redirects the address of an output.

So let me propose:

txmodifypayee txid modifications

Where modifications is an array containing objects with fields:

{
    'outnum' : 0,
    'address': "3LXPWUpTGKmeatx6NpyQ8A8TZr2GCXkK4u"
}

The address would have to take up the same amount of space as the current address at that outnum.

The command succeeds or fails "atomically". If it succeeds, then the old txid is no longer passable to txdiscard or txsend. If it fails, then the old txid can still be passed to txdiscard or txsend.

Thoughts @niftynei @cdecker @rustyrussell ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureAimed at improving the existing functionality or a new feature that provides additional valuefunding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions