Comments (2)
Pierre-Marie [email protected] writes:
Hello,
This is just a matter of reversing the array, but the comment is a bit misleading
message open_anchor { // Transaction ID of anchor. required sha256_hash txid = 1;
See https://github.com/ElementsProject/lightning/blob/master/bitcoin/tx.c#L232
We always encode hashes as big-endian. That's the normal encoding for SHA.
Unfortunately, bitcoind uses little-endian for transaction hashes for
reasons unknown. It uses big-endian for block hashes though!
It's wrong. I keep this script around to fix it up to paste into block:
( cat > hex_rev.c; chmod a+x hex_rev.c )
// 2>/dev/null; set -e; OUT=/tmp/basename $0 .c
; if [ ! -f "$OUT" ] || [ "$OUT" -ot "$0" ]; then gcc -Wall -g -o "$OUT".$$ $0 && mv "$OUT".$$ "$OUT"; fi; exec "$OUT" "$@"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <err.h>
#include <stdbool.h>
static char hexchar(unsigned int x)
{
if (x < 10)
return '0' + x;
else
return 'a' - 10 + x;
}
static void print_hex(const unsigned char *val, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
printf("%c%c", hexchar(val[i] >> 4), hexchar(val[i] % 16));
printf("\n");
}
static bool char_to_hex(unsigned char *val, char c)
{
if (c >= '0' && c <= '9') {
*val = c - '0';
return true;
}
if (c >= 'a' && c <= 'f') {
*val = c - 'a' + 10;
return true;
}
if (c >= 'A' && c <= 'F') {
*val = c - 'A' + 10;
return true;
}
return false;
}
static bool from_hex(const char *str, size_t slen, void *buf, size_t bufsize)
{
unsigned char v1, v2;
unsigned char *p = buf;
while (slen > 1) {
if (!char_to_hex(&v1, str[0]) || !char_to_hex(&v2, str[1]))
return false;
if (!bufsize)
return false;
*(p++) = (v1 << 4) | v2;
str += 2;
slen -= 2;
bufsize--;
}
return slen == 0 && bufsize == 0;
}
static void reverse_hash(unsigned char *hex, size_t len)
{
unsigned int i;
for (i = 0; i < len / 2; i++) {
unsigned char tmp = hex[i];
hex[i] = hex[len - 1 - i];
hex[len - 1 - i] = tmp;
}
}
int main(int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++) {
unsigned char hex[strlen(argv[i]) / 2];
if (!from_hex(argv[i], strlen(argv[i]), hex, sizeof(hex)))
errx(1, "Bad hex '%s'", argv[i]);
reverse_hash(hex, sizeof(hex));
print_hex(hex, sizeof(hex));
}
return 0;
}
from lightning.
Fair enough!
Cheers
from lightning.
Related Issues (20)
- Can't run node since upgrading to v23.08.1 HOT 3
- Channel force-closed and dont think the funds made it back to me, fees of 46k sat for one HTLC
- Add configuration to subscribe to list of notifications
- Documentation consolidation based on OpenRPC standards
- Disable clnrest.py HOT 1
- onchain invoice payments should warn if payment after expiry HOT 4
- channeld should tell lightningd once reestablish exchanged
- utxoset table unexpectedly large
- adding FetchInvoice grpc call to node proto
- renepay: Probability costs for small amounts zero? HOT 2
- Error when using 12 words for lightning-hsmtool generatehsm HOT 1
- Remove `msat` suffix from all clnrest responses
- Install takes forever(?) HOT 6
- Feature Engineering in renepay seems a bit unstructured and arbitrary HOT 1
- Remove the JSON decoder global override to convert _msat fields to Millisatoshi
- channeld sent bad reestablish revocation_number: 0 vs 158147 HOT 1
- My lightningd cannot run as systemd service HOT 2
- splice: HSM WIRE_HSMD_SIGN_SPLICE_TX capability not correctly checked
- hsmd, splicing: wrong remote per-commit point provided when signing splice remote tx HOT 2
- cln-application: bkpr dashboard rpc methods HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightning.