diff -uNr a/gbw-signer/README b/gbw-signer/README --- a/gbw-signer/README 55581d8ede59ca7a2de3f7b0210c39b5580a37a5ade835b87d5869502c50952a406d2c447baad4a84c306192ab3c1c297bcfa01d64e68d6fc483485acce1a96d +++ b/gbw-signer/README 217f814a4a4a15706c6aea550b418e7d9f20b993178b1880e444c42d6d087c40e1589249eacb620a3ff8cea372e32e15978338784d7df16cda2ff6d6ee4e57fa @@ -20,11 +20,11 @@ 1. Create the top-level /package directory if necessary and place the tree at its fully version-qualified path: mkdir -p /package - cp -r /YOUR/PATH/TO/gbw-signer /package/gbw-signer-3 + cp -r /YOUR/PATH/TO/gbw-signer /package/gbw-signer-4 2. Run the install script from the above directory: - cd /package/gbw-signer-3 + cd /package/gbw-signer-4 sh package/install ECC cache generation will take a noticeable time, depending on hardware, though hopefully not so much as to suggest preparing a beverage. diff -uNr a/gbw-signer/command/gbw-signer b/gbw-signer/command/gbw-signer --- a/gbw-signer/command/gbw-signer 103225e8a2ec39d5f86e1bf0b63ed780daa6c2ad73dc29baabc3c97bb55bb9b7cfcc319726937bfc56060605bd86244c50f9e867ba28ffedf926da88e77dddfe +++ b/gbw-signer/command/gbw-signer 58f9587de97715f69c94b974a5bf77e682288e125d106b74ba3ccea590c43f948adb4bd17d57a84075d6fe4387a1d003e69906d72d655ee6d1c82b36f3c2627e @@ -1,2 +1,2 @@ #!/bin/sh -exec /usr/bin/gscm /package/gbw-signer-3/library/gbw-signer.scm "$@" +exec /usr/bin/gscm /package/gbw-signer-4/library/gbw-signer.scm "$@" diff -uNr a/gbw-signer/library/gbw-shell.sh b/gbw-signer/library/gbw-shell.sh --- a/gbw-signer/library/gbw-shell.sh bb862e99e6371a5a69f0485035062fbe1164e9bee636afd1f8540ab718608bcd689ce5af1ede9e54b89453b361aabc3ea14fd21989cd0d850e2d8a524f279f24 +++ b/gbw-signer/library/gbw-shell.sh c8e35cb1e832e97ea10fc88b05b1fc0247dc00729407a19e7d1044b2afad86eea950f67fc8e78efe8fa35a08638d29967a1c115c5df3eaacf787de3282410b05 @@ -63,9 +63,14 @@ fi (cd "$GBW_OLDPWD" && - tar -cf - -C "$GBW_DIR" wallet | gpg --encrypt --armor --recipient "$GBW_RECIPIENT" --output "$GBW_FILENAME{new}" && + # redirect instead of using gpg --output as it annoyingly prompts to overwrite + new=`mktemp "$GBW_FILENAME".XXXXXX` && + (cd "$GBW_DIR" && tar -cf - wallet && touch ok) | gpg --encrypt --armor --recipient "$GBW_RECIPIENT" > "$new" && + # catch tar failure from piped subshell (it should already have shown its error) + [ -e "$GBW_DIR"/ok ] && + rm -f "$GBW_DIR"/ok && sync && - mv -f "$GBW_FILENAME{new}" "$GBW_FILENAME") + mv -f "$new" "$GBW_FILENAME") } gbw-discard () { diff -uNr a/gbw-signer/library/gbw-signer.scm b/gbw-signer/library/gbw-signer.scm --- a/gbw-signer/library/gbw-signer.scm 28cd962b6acc4468b5ebecbdcce4a39f85407572f85e7027b07f27c377a48b55430363d231dfd0a6b15b07346b85d371f675dfee74455e1af8e9ce06a3091b3d +++ b/gbw-signer/library/gbw-signer.scm 76083c327fe9cf4bf9d87f34c8903a68a94b7e0e4eb02662b8ae583684f47f0cb5d1d593cfdccf5d13ca250f9da0c754282998f0687610fedf8c7c1a499d1681 @@ -3,7 +3,7 @@ ;;; Knobs -(define *install-path* "/package/gbw-signer-3") +(define *install-path* "/package/gbw-signer-4") (define *rng-port* (delay (open-input-file "/dev/urandom"))) @@ -609,8 +609,9 @@ (let* ((prevouts (cons p prevouts)) (prevout-total (apply + (map get-value prevouts))) (size (estimate-tx-size prevouts (force outputs+change-dummy))) - ;; fee computation per wallet.cpp CWallet::CreateTransaction - (fee (* fee/kb (+ 1 (quotient size 1000)))) + ;; fee computation amended as in bitcoin_tx_fee_cleanup.vpatch + ;; [http://jfxpt.com/2021/a-tetrad-of-tuneups-for-bitcoind/] + (fee (quotient (* fee/kb size) 1024)) (change-val (- prevout-total (force output-subtotal) fee))) (if (negative? change-val) (add-input prevouts) (let* ((outputs (shuffle @@ -710,15 +711,20 @@ ("5KC4ejrDjv152FGwP386VD1i2NYc5KkfSMyv1nGy1VGDxGHqVY3" "1F5y5E5FMc5YzdJtB9hLaUe43GDxEKXENJ")))) (define (help) + (define (show-cmd-usage entry) + (newline) + (display-line (string-append (car entry) " - " (caddr entry)))) + (display-line "Usage: gbw-signer COMMAND [ARGS]") - (newline) - (display-line "Available commands:") - (for-each (lambda (c) - (newline) - (display (car c)) - (display " - ") - (display-line (caddr c))) - commands)) + (if (null? *args*) + (begin + (newline) + (display-line "Available commands:") + (for-each show-cmd-usage commands)) + (let* ((cmd (pop-arg)) + (entry (assoc cmd commands))) + (if entry (show-cmd-usage entry) + (display-line (string-append "No such command - " cmd)))))) ;;; CLI dispatch @@ -730,7 +736,7 @@ ("priv2wif" ,priv2wif "Print WIF encoding of a hex private key fed to standard input.") ("import-wif" ,import-wif "Import WIF private key fed to standard input into the 'keys' directory by converting to hex and computing the address, including any compression tag (though such tag is currently unsupported by other commands).") ("test" ,test "Run the (rather limited) test suite.") - ("help" ,help "Show this usage."))) + ("help" ,help "Display help for a given command or all commands."))) (if (not (null? *args*)) ;; allows loading at REPL (let* ((prog-name (pop-arg)) diff -uNr a/gbw-signer/manifest b/gbw-signer/manifest --- a/gbw-signer/manifest dd4493b1b03bf16a25c69324ecf2f82e9d130afeae7f4d5d8c53aee07e251c7ba1e6cfbe4ee72c5dc5f9700ccb2df92fa000a2c3b59f4756256df36c7b939afe +++ b/gbw-signer/manifest 8ffc786c86d9eef8097fe174680c34ebb4a5e5981fd79f880e3ca0796b9108b3dd009d8cac49a6cb53ae3f7f4aa4740454af22d12ee4a1b61cd7e142f9f53487 @@ -3,3 +3,4 @@ 739066 gbw-signer_static_bit_ops_1 jfw Restructure the library of arithmetic and bitwise operators on fixed-width integers to be separately instantiated for given bit widths, rather than tracking the width dynamically in the operand objects (reindenting deliberately suppressed for patch readability). This saves substantial redundant runtime computations, data wrangling and checking, at a cost of less helpful error reporting and slightly more setup for callers. Correct an ass-backwards comment as to which bits are padding; expand comments generally, mainly to note variable ranges. Replace much generic arithmetic with with faster fixnum arithmetic where applicable. Move toward curried forms of bit shift and rotation operators to allow pre-analysis of shift size. Update hash function library for the changes. Bump version and fix "check" script to find the code by relative path rather than globally active version. Hashing speedup on my machine (x86_64, gscm 0.40.6) is around 4x. 739066 gbw-signer_static_bit_ops_2 jfw Further optimize shifts and rotations as hinted in comments by propagating curried arguments to the internals, allowing precomputed divisions. Total hashing speedup for the series increases to 5x. 739066 gbw-signer_static_bit_ops_reindent jfw Full automated reindent of lisp code affected by this series. This will make for dreadful patch reading; perhaps best to verify it instead by doing your own reindent on the affected files in their prior state, using a suitably-configured editor, and comparing results to the patch output. +853499 gbw-signer_bytewise_fees_etc jfw Now version 4: tightened transaction fee computation, not rounding to KB, following earlier bitcoind change. Halt on tar errors in gbw-save, such as from a deleted wallet directory. Give subcommand-specific help as in gbw-node. diff -uNr a/gbw-signer/package/install b/gbw-signer/package/install --- a/gbw-signer/package/install 317db1eab91df4649c6be0554773da917cc7ae33040d0c688d6b973b22cb09ab8ebc7ecd99bc4f94e890e99ad3caa2fa2ea32111365a6081d8e2007d26a47107 +++ b/gbw-signer/package/install 47590f71b942303239439f4d2385942fd9ddcbb86e1410395d19d07b91d3abdf8201fb0d026bf4f5dc4394489608c14a06e60a92f0e797436c3d534aeeb9395a @@ -2,7 +2,7 @@ set -e P=gbw-signer -V=3 +V=4 cd /package/$P-$V # Versioned path duplicated in: