Skip to content

Commit d04feb3

Browse files
committed
support macos
1 parent 1056cf9 commit d04feb3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ With the receiver's approval of the transfer, the transaction can be signed and
485485
broadcast:
486486
```sh
487487
bdk -n regtest wallet -w issuer -d "$DESC_TYPE($xprv_der_0)" \
488-
sign --psbt $(base64 -w0 "data0/$PSBT")
488+
sign --psbt $(cat data0/$PSBT | base64 | tr -d '\r\n')
489489
# example output:
490490
# {
491491
# "is_finalized": true,

demo.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ check_schemata_version() {
165165

166166
check_tools() {
167167
_subtit "checking required tools"
168-
local required_tools="base64 cargo cut docker grep head jq sha256sum"
168+
local required_tools="base64 cargo cut docker grep head jq nc sha256sum tr"
169169
for tool in $required_tools; do
170170
if ! which "$tool" >/dev/null; then
171171
_die "could not find reruired tool \"$tool\", please install it and try again"
@@ -305,12 +305,8 @@ start_services() {
305305
_subtit "stopping services"
306306
docker compose down
307307
_subtit "checking bound ports"
308-
if ! which ss >/dev/null; then
309-
_log "ss not available, skipping bound ports check"
310-
return
311-
fi
312308
# see docker-compose.yml for the exposed ports
313-
if [ -n "$(ss -HOlnt 'sport = :50001')" ];then
309+
if nc -z localhost 50001;then
314310
_die "port 50001 is already bound, electrs service can't start"
315311
fi
316312
_subtit "starting services"
@@ -439,7 +435,7 @@ transfer_create() {
439435

440436
## extract PSBT data
441437
local decoded_psbt
442-
decoded_psbt="$(_trace "${BCLI[@]}" decodepsbt "$(base64 -w0 "$send_data/$PSBT")")"
438+
decoded_psbt="$(_trace "${BCLI[@]}" decodepsbt "$(base64_file_nowrap "$send_data/$PSBT")")"
443439
if [ $DEBUG = 1 ]; then
444440
_log "showing PSBT including RGB transfer data"
445441
echo "$decoded_psbt" | jq
@@ -478,9 +474,10 @@ transfer_complete() {
478474
local der_xprv der_xpub psbt_finalized psbt_signed
479475
der_xprv=${DER_XPRV_MAP[$SEND_WLT]}
480476
der_xpub=${DER_XPUB_MAP[$SEND_WLT]}
477+
481478
psbt_signed=$(_trace "$BDKI" -n $NETWORK wallet -w "$SEND_WLT" \
482479
-d "${DESC_TYPE}($der_xprv)" sign \
483-
--psbt "$(base64 -w0 "$send_data/$PSBT")")
480+
--psbt "$(base64_file_nowrap "$send_data/$PSBT")")
484481
psbt_finalized=$(echo "$psbt_signed" \
485482
| jq -r 'select(.is_finalized = true) |.psbt')
486483
[ -n "$psbt_finalized" ] || _die "error signing or finalizing PSBT"
@@ -525,6 +522,15 @@ help() {
525522
echo " -v --verbose enable verbose output"
526523
}
527524

525+
base64_file_nowrap() {
526+
# This function encodes the specified file to base64 format without wrapping lines.
527+
# By default, Linux systems wrap base64 output every 76 columns. We use 'tr -d' to remove whitespaces.
528+
# Note that the option '-w0' for 'base64' doesn't work on Mac OS X due to different flags.
529+
# Arguments:
530+
# $1: File path to be encoded
531+
cat "$1" | base64 | tr -d '\r\n'
532+
}
533+
528534

529535
# cmdline arguments
530536
while [ -n "$1" ]; do

0 commit comments

Comments
 (0)