Author

Topic: Locktime, low fee & change address [personal contest] (Read 206 times)

legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
In Electrum, you'll have to manually broadcast it and even if you save it locally, it wont be automatically sent after the nLocktime passed.
Since locktime is being used here just as a proof that it has been used, and not because we want to actually set a specific locktime, then just set a locktime in the past as I suggested above. The transaction will then broadcast normally at the time of signing. If OP wants to prove that he changed the locktime and sets it to some block/date in the future, then there is no proof there that he didn't just create the transaction at that future time and broadcast it immediately.
Since it's a "personal contest", that will do.
But he can at least set it to the next 1~3 block(s) so that he could 'try' what will happen to the transaction when the locktime doesn't go past yet.
legendary
Activity: 2268
Merit: 18711
The fees in a transaction are dictated by the number of inputs and outputs and by the type of those inputs and outputs. Using "pay to many" will only increase the fee if you end up using more outputs for your transaction. If your transaction was going to have one receiving address and a change address, and you change that to two receiving addresses via pay to many, the fees will be identical if the address types are the same, and only very marginally different if you change one output from P2PKH to P2SH.

If your wallet doesn't, then you would need to do so manually.
In Electrum, you'll have to manually broadcast it and even if you save it locally, it wont be automatically sent after the nLocktime passed.
Since locktime is being used here just as a proof that it has been used, and not because we want to actually set a specific locktime, then just set a locktime in the past as I suggested above. The transaction will then broadcast normally at the time of signing. If OP wants to prove that he changed the locktime and sets it to some block/date in the future, then there is no proof there that he didn't just create the transaction at that future time and broadcast it immediately.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
-snip-
Ah yeah, my bad, but you got it exactly right. I want to control my change addresses manually. I see you can unhook "use change address" in Electrum. I wonder how that looks... Your input gets as output as well together with the withdrawal address?

Anyway, if any of you knows the easiest way to put a P2HS as change address from a P2PKH, please let me know. This could be smart to do if you want to transfer your funds to segwit to get lower fees, huh? So you just wait to transfer them till the next time you gonna pay for something else. I know you can do "pay to many" as well in electrum, but that makes the fees higher i guess.
It cant be done in the same HD wallet since Electrum can only make one script type per wallet.
It can be done by either using "Imported" Electrum wallet with P2SH and P2PKH addresses
or Multiple Electrum wallets, one legacy and one P2SH-SegWit (the legacy and P2SH wallet types cannot be created in the latest version using the standard method).
Then use "pay to many" as instructed by ranochigo.

For the fee, the trick is to minimize the input (preferably single input) to minimize the transaction's size, then use the 'Advanced' preview to manually set the absolute fee to 300sat and the locktime as well.

Here's a sample transaction that has all of your requirements (in Testnet), made with Electrum:
Code:
{
    "addresses": [
        "mnGWeTPSpDQDaAUberY2yXoUBVKdc929oQ",
        "tb1qs7nsd3me4tecjy0dxtvu7fv5j77wtlyyk79g46",
        "2NDtnDqpu989KZCFheNLbcyrE3Uhh39Dd37"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 299,
    "hash": "02131283383a61cae96659d17ba8037d1a2eb4fbf63b63a464a1ca9c8b641c28",
    "inputs": [
        {
            "addresses": [
                "mnGWeTPSpDQDaAUberY2yXoUBVKdc929oQ"
            ],
            "age": 2131727,
            "output_index": 0,
            "output_value": 208136,
            "prev_hash": "27df12d3196bb002529aaebc8c38c2ff9548965f1226bc863e8de2b76076fda1",
            "script": "473044022025c3e1fb29d4771f77b1ed9b9f046c35ab5e92521a0c85a87caf39ff9ded4116022014566644d98f5ec0041dea6af247bb087598b7c2a90aa41f26bc8dec9e4078f9012103bb9863910b98ed804e44535ff8373df729b0d68398634ec70ebabbd399da58db",
            "script_type": "pay-to-pubkey-hash",
            "sequence": 4294967293
        }
    ],
    "lock_time": 1640966421,
    "opt_in_rbf": true,
    "outputs": [
        {
            "addresses": [
                "tb1qs7nsd3me4tecjy0dxtvu7fv5j77wtlyyk79g46"
            ],
            "script": "001487a706c779aaf38911ed32d9cf259497bce5fc84",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 100000
        },
        {
            "addresses": [
                "2NDtnDqpu989KZCFheNLbcyrE3Uhh39Dd37"
            ],
            "script": "a914e27cd04be97a13089ba664307599dca4b379a2bb87",
            "script_type": "pay-to-script-hash",
            "value": 107837
        }
    ],
}

Fee: 1.4sat/vB @ 220vB | 299 satoshi
Locktime set to 13 days from now / next year (1640966421)
P2PKH input: mnGWeTPSpDQDaAUberY2yXoUBVKdc929oQ
Sent to P2WPKH: tb1qs7nsd3me4tecjy0dxtvu7fv5j77wtlyyk79g46
P2SH-P2WPKH Change address: 2NDtnDqpu989KZCFheNLbcyrE3Uhh39Dd37

Quote from: Sim33
One more question (i probably get more later when i try the transaction):
In case of using locktime, does it have to require two actions? One for locking and one for receiving (broadcasting the transaction) or is it possible to like "auto broadcast" at a specific block/time?
In Electrum, you'll have to manually broadcast it and even if you save it locally, it wont be automatically sent after the nLocktime passed.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
Ah yeah, my bad, but you got it exactly right. I want to control my change addresses manually. I see you can unhook "use change address" in Electrum. I wonder how that looks... Your input gets as output as well together with the withdrawal address?
Change gets sent back to the same address.
Anyway, if any of you knows the easiest way to put a P2HS as change address from a P2PKH, please let me know. This could be smart to do if you want to transfer your funds to segwit to get lower fees, huh? So you just wait to transfer them till the next time you gonna pay for something else. I know you can do "pay to many" as well in electrum, but that makes the fees higher i guess.
Use pay to many, it doesn't increase the fees. For the first line, use the address of your intended recipient and the amount (address,BTC AMOUNT) and for the second line, use this: (Change address, !). The exclamation mark tells the client to send the remainder to that address.
Thank you so much for that screenshot, really helps me. I just noticed I need balance on my Electrum account to get to this step, auch. Maybe I can connect my trezor to it, hm. I came across the testnet as well, is that somehing to recommand? Anyone got easy guides?
Most people don't need to mess with the nlocktime so I wouldn't really recommend for you to do so either on mainnet though it is relatively risk-free. You can run Electrum in testnet, get some testnet coins from the faucets and experiment with it.
One more question (i probably get more later when i try the transaction):
In case of using locktime, does it have to require two actions? One for locking and one for receiving (broadcasting the transaction) or is it possible to like "auto broadcast" at a specific block/time?
Your wallet will automatically broadcast the transaction once the transaction becomes final (ie. the specified requirement is met). If your wallet doesn't, then you would need to do so manually.
newbie
Activity: 2
Merit: 7
Lots of great answers, this is a great place to learn about blockchain. Should have come here long time ago.

Thanks everyone for participating.

-snip-
3) Send from a P2PKH address (legacy, prefix 1) and set P2HS (prefix 3 address) format.
What do you mean by this? From p2pk then set it as p2sh?

In the paragraphs below it, it seems like you meant "...and set a p2sh change address". Is it?

Ah yeah, my bad, but you got it exactly right. I want to control my change addresses manually. I see you can unhook "use change address" in Electrum. I wonder how that looks... Your input gets as output as well together with the withdrawal address?

Anyway, if any of you knows the easiest way to put a P2HS as change address from a P2PKH, please let me know. This could be smart to do if you want to transfer your funds to segwit to get lower fees, huh? So you just wait to transfer them till the next time you gonna pay for something else. I know you can do "pay to many" as well in electrum, but that makes the fees higher i guess.

ranochigo:
Thank you so much for that screenshot, really helps me. I just noticed I need balance on my Electrum account to get to this step, auch. Maybe I can connect my trezor to it, hm. I came across the testnet as well, is that somehing to recommand? Anyone got easy guides?

One more question (i probably get more later when i try the transaction):
In case of using locktime, does it have to require two actions? One for locking and one for receiving (broadcasting the transaction) or is it possible to like "auto broadcast" at a specific block/time?

Thank you all again for replying, Ive red all of the posts.

 

legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
I'm just curious, where is this functionality implemented in Electrum? I haven't noticed it in any of the GUI wallets I used (Core, Electrum, Atomic, OWNR, Mycelium).
You'll have to select Advanced Preview.



Can't remember if Core has it, don't recall seeing it. You can select both unix and block height.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
Electrum allows you to set locktime and infact, most wallets already preset a locktime for every of your transaction by default.

I'm just curious, where is this functionality implemented in Electrum? I haven't noticed it in any of the GUI wallets I used (Core, Electrum, Atomic, OWNR, Mycelium).
legendary
Activity: 2268
Merit: 18711
Every transaction has a locktime. Most commonly this is automatically set by your wallet at either 0 or the height of the last block. If you want to prove to your friend that you've manually changed the locktime in a transaction, you can't just pick a future block since your transaction may look exactly the same as it would have done had you simply signed and broadcast it just after that future block was mined.

I'm not aware of any wallet which specifies a unix time for locktime by default, so you could pick a unix time. Or more simply just agree on a block height which has already past, say 500,000 for example, before you create the transaction.

I would agree with the above posters that this is all very easy to do in Electrum.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
legendary
Activity: 3472
Merit: 10611
Fee blow 300 sats is abit scary cause its a huge risk for the transaction to stay stuck for some time. I know using RBF will help me out if things are getting nasty, but it wont help me much with the task itself. Impossible you say? Well, I have seen several transactions made it.
It is not scary at all. Bitcoin fees are most of the times sitting at 1 satoshi/vbytes and a transaction such as the one you are testing is about 190 bytes (1 P2PKH input and 1 P2SH output) which means the minimum fee you can pay is 190 satoshi and the 300 satoshi cap is going to give you about 1.5 sat/byte rate which is slightly higher than that minimum.

You can use this tool to play with transaction size by changing the input/output type and count: https://coinb.in/#fees

2. https://bitcoinfees.earn.com say you only need to spend 103 sats per byte.
Please stop suggesting this malicious website.
legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
Electrum allows you to set locktime and infact, most wallets already preset a locktime for every of your transaction by default. Locktime simply means that your transaction won't be relayed until the locktime has passed.

Setting a fixed fee is okay, but you would be looking to set a specific fee rate instead of a fixed static fee. Chances are, your transaction might not get relayed if the fees are too low relative to your transaction size. You should instead be trying to fix a fee rate. You can still use legacy addresses and send to a P2SH address without any problems, though wallets like Electrum has started to deprecate those.

Bitcoin Core or Electrum would be your best bet. Please do not manually script your own transaction if you have no idea what you're doing. Using coinb.in without knowing exactly what you're supposed to do is a recipe for disaster.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
-snip-
3) Send from a P2PKH address (legacy, prefix 1) and set P2HS (prefix 3 address) format.
What do you mean by this? From p2pk then set it as p2sh?

In the paragraphs below it, it seems like you meant "...and set a p2sh change address". Is it?
legendary
Activity: 3374
Merit: 3095
Playbet.io - Crypto Casino and Sportsbook
There is a tool from Coinb.in where you can make a lock time transaction. I didn't test it yet but you can try

Here's the link https://coinb.in/#newTimeLocked

You can also make a lock time transaction from this link https://coinb.in/#newTransaction then go to advance and look for lock time then set the specific time but I don't know how to set up the lock time under the advanced mode compared to the above link which is easy to set up.
copper member
Activity: 2856
Merit: 3071
https://bit.ly/387FXHi lightning theory
I think all this can be done in electrum:
1. This one can just be edited on the transaction preview screen
2. Check pooyas response
3. You can import private keys with different types of addresses into electrum too.
newbie
Activity: 2
Merit: 7
Hello guys,

Im new here, but not new to Bitcoin. Thank you in advance for your warm welcome, thank you thank you.

Me and my friend have been using blockchain techonology for echonomic speculation for few years now. Now when that has become such a mainstream we are bored of it and wanna try to learn more about how it actually works. We know all the basic stuff as change address, mining, mempool, mixing etc. But we recently started to challenge eachother with tasks. So my task now is following:

Do the following in one same transaction:

1) Use locktime

2) Fee below 300 sats

3) Send from a P2PKH address (legacy, prefix 1) and set P2HS (prefix 3 address) format.


Now, locktime aint hard with the correct software. I know that Trezor can use it easy, but I got no Trezor. Other software or coding lines is  appreciated.

Fee blow 300 sats is abit scary cause its a huge risk for the transaction to stay stuck for some time. I know using RBF will help me out if things are getting nasty, but it wont help me much with the task itself. Impossible you say? Well, I have seen several transactions made it.

I have never set a manual change address. Ive only used the automatically given ones. So here im quite lost.

Why on earth havent you just googled or youtubed it? Well, I have, but try to search on something technical on cryptocurrency on the internet without getting spammed by youtubers trying to get you to buy shitcoins.

And you might call me a cheater. Well, jokes on you. All help is allowed, the main goal is to learn.

So if anyone of you nice bitcoin talkers can help me out or share your experience, I would really much appreciate it.

Peace out, Sim33.
Jump to: