Skip to content

Removed redundancies in withdraw and fundchannel. - #1399

Merged
cdecker merged 1 commit into
ElementsProject:masterfrom
wythe:specify_output
May 3, 2018
Merged

cdecker merged 1 commit into
ElementsProject:masterfrom
wythe:specify_output

Conversation

@wythe

@wythe wythe commented Apr 20, 2018

Copy link
Copy Markdown
Contributor

No new functionality, just a continuation of my work toward completing #665.

I removed the common members of struct withdrawal and struct fund_channel
and placed them in a new struct wallet_tx. Then it was fairly straightforward
to reimplement the existing code in terms of wallet_tx.

Since I made some structural changes I wanted to get this approved before I
go any farther.

@ZmnSCPxj

Copy link
Copy Markdown
Contributor

ACK 2b79542

Please rebase and we should merge this too...

@wythe

wythe commented Apr 25, 2018

Copy link
Copy Markdown
Contributor Author

I'm not really sure where I went wrong here. The tests sometimes pass and sometimes don't on my home machine. It might be better to discard this pull request and let me recreate another.

@wythe

wythe commented Apr 27, 2018

Copy link
Copy Markdown
Contributor Author

Oh I didn't realize master was broken atm. Will wait.

@cdecker cdecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Excellent work @wythe, just some minor nits

Comment thread common/wallet_tx.c Outdated
wtx->desttok = NULL;
}

bool wtx_json_get_params(struct wallet_tx * tx, const char * buffer,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd rather have this in the JSON-RPC file, since this adds a tight coupling of the two.

Comment thread common/wallet_tx.c Outdated
}

bool wtx_json_get_params(struct wallet_tx * tx, const char * buffer,
const jsmntok_t *params, const char * dest)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dest -> destJsonKey?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's also seems to conflate the destination address and destination node_id, those are two very different concepts and should be treated differently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I noticed that too. They are different concepts but just happen to be used exactly the same. I will get to work on the changes this afternoon.

@wythe
wythe force-pushed the specify_output branch 3 times, most recently from c130fe0 to 5719cb9 Compare April 29, 2018 23:24
Comment thread lightningd/jsonrpc.h Outdated
const jsmntok_t *tok, const u8 **scriptpubkey);

/* A specialized get_params used for both withdraw and fundchannel */
bool json_wtx_get_params(struct wallet_tx * tx, const char * buffer,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest using a json_tok_wtx rather than replacing json_get_params: we may want to add different arguments to fundchannel vs withdraw in the future. So you would retain json_get_params but replace the satoshi-parsing with json_tok_wtx instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Very good. I'm on it.

@wythe

wythe commented May 1, 2018

Copy link
Copy Markdown
Contributor Author

Ready to go.

Comment thread common/wallet_tx.h Outdated

bool all_funds;
const jsmntok_t *desttok;
const jsmntok_t *sattok;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we do not really need the jsmntok here? They only really make sense in combination with the buffer that holds all of their actual data, and we are not keeping a copy of the buffer anyway. I think for json_tok_wtx you can just receive the sattok as an argument, and let the caller handle destination as it sees fit.

@wythe
wythe force-pushed the specify_output branch from 9a513e2 to cfe75b0 Compare May 2, 2018 15:09
@wythe

wythe commented May 2, 2018

Copy link
Copy Markdown
Contributor Author

Removed jsmn toks from wallet_tx. It cleaned up nicely.

No new functionality, just a continuation of my work toward completing ElementsProject#665.

I removed the common members of `struct withdrawal` and `struct fund_channel`
and placed them in a new `struct wallet_tx`.  Then it was fairly straightforward
to reimplement the existing code in terms of `wallet_tx`.

Since I made some structural changes I wanted to get this approved before I
go any farther.

Added 'all' to fundchannel help message.
@wythe
wythe force-pushed the specify_output branch from cfe75b0 to 9c7a7bc Compare May 2, 2018 15:49
Comment thread lightningd/jsonrpc.c
return ADDRESS_PARSE_UNRECOGNIZED;
}

bool json_tok_wtx(struct wallet_tx * tx, const char * buffer,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other json_tok_* functions are usually of the form bool json_tok_whatever(const char *buffer, const jsmntok_t *tok, struct whatever *output) and do not call command_fail themselves. This is acceptable, though.

@ZmnSCPxj

ZmnSCPxj commented May 3, 2018

Copy link
Copy Markdown
Contributor

ACK 9c7a7bc

@cdecker cdecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 9c7a7bc

@cdecker
cdecker merged commit 7767b68 into ElementsProject:master May 3, 2018
@wythe
wythe deleted the specify_output branch May 3, 2018 19:13
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.

3 participants