container: hledger-flow: electrum: add lightning, backwards compat
*WARNING*: lightning support is a WIP due to an unresolved electrum lightning history bug (see docker-finance #227). This commit is needed for backwards compatibility, as the new electrum format will break import - even if lightning is never used.
This commit is contained in:
@@ -15,74 +15,191 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fields txid,label,confirmations,value_without_fee,fiat_value,fee,fiat_fee,timestamp,direction,subaccount
|
||||
# TODO: *WARNING*: lightning support is a WIP due to an unresolved electrum lightning history bug (see docker-finance #227)
|
||||
|
||||
fields oc_hash,ln_hash,label,confirmations,oc_amount,ln_amount,fiat_value,network_fee,fiat_fee,timestamp,direction,subaccount
|
||||
|
||||
# Electrum exports to localtime
|
||||
date-format %Y-%m-%d %H:%M:%S %z
|
||||
date %timestamp
|
||||
|
||||
# Actual description must be kept as a notes tag
|
||||
description %timestamp
|
||||
|
||||
# Treat the Electrum 'label' field as notes
|
||||
comment txid:%txid, notes:%label, direction:%direction
|
||||
|
||||
account1 assets:electrum:%subaccount:BTC
|
||||
amount %value_without_fee BTC
|
||||
amount %oc_amount BTC
|
||||
|
||||
if %direction ^OUT$
|
||||
amount -%value_without_fee BTC
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction
|
||||
|
||||
if %ln_hash [0-9a-z]
|
||||
comment txid:%oc_hash, ln_hash:%ln_hash, notes:%label, direction:%direction
|
||||
|
||||
#
|
||||
# Set account based 'label' keywords
|
||||
#
|
||||
|
||||
# IN
|
||||
#
|
||||
|
||||
if %direction ^IN$
|
||||
account2 equity:electrum:%subaccount:withdrawal:BTC
|
||||
|
||||
if %direction ^IN$
|
||||
& %oc_amount [1-9]
|
||||
& %ln_amount [1-9]
|
||||
amount2 -%oc_amount BTC
|
||||
account3 assets:electrum:%subaccount:ln_locked_payable:BTC
|
||||
amount3 %ln_amount BTC
|
||||
account3 assets:electrum:%subaccount:BTC
|
||||
amount4 -%ln_amount BTC
|
||||
|
||||
if %direction ^IN$
|
||||
& %oc_amount ^[^1-9]*$
|
||||
& %ln_amount [1-9]
|
||||
amount %ln_amount BTC
|
||||
amount2 -%ln_amount BTC
|
||||
|
||||
# Label: lightning channels
|
||||
|
||||
if %direction ^IN$
|
||||
& %oc_amount [1-9]
|
||||
& %ln_amount [1-9]
|
||||
& %label ^Close channel
|
||||
amount %ln_amount BTC
|
||||
account2 assets:electrum:%subaccount:ln_locked_payable:BTC
|
||||
|
||||
# Labels: income
|
||||
|
||||
if %direction ^IN$
|
||||
& %label (Income|Payment)
|
||||
account2 income:electrum:%subaccount:BTC
|
||||
comment txid:%txid, notes:%label, direction:%direction, taxed_as:INCOME
|
||||
comment2 %timestamp,INCOME,electrum:%subaccount:BTC,BTC,%value_without_fee,USD,%fiat_value,%label
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction, taxed_as:INCOME
|
||||
comment2 %timestamp,INCOME,electrum:%subaccount:BTC,BTC,%oc_amount,USD,%fiat_value,%label
|
||||
|
||||
if %direction ^IN$
|
||||
& %label (Income|Payment)
|
||||
& %ln_amount [1-9]
|
||||
comment ln_hash:%ln_hash, notes:%label, direction:%direction, taxed_as:INCOME
|
||||
comment2 %timestamp,INCOME,electrum:%subaccount:BTC,BTC,%ln_amount,USD,%fiat_value,%label
|
||||
|
||||
# Labels: gifts
|
||||
# NOTE: fiat_value must be manually updated in custom rules if cost-basis will be different than given fiat_value
|
||||
|
||||
# TODO: add regex for donate/donation
|
||||
# TODO: separate donations from gifts subaccount
|
||||
if %direction ^IN$
|
||||
& %label Gift
|
||||
& %oc_amount [1-9]
|
||||
account2 income:electrum:%subaccount:gifts:BTC
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction, taxed_as:GIFTIN
|
||||
comment2 %timestamp,GIFTIN,electrum:%subaccount:BTC,BTC,%oc_amount,USD,%fiat_value,%label
|
||||
|
||||
if %direction ^IN$
|
||||
& %label Gift
|
||||
account2 income:electrum:%subaccount:gifts:BTC
|
||||
comment txid:%txid, notes:%label, direction:%direction, taxed_as:GIFTIN
|
||||
comment2 %timestamp,GIFTIN,electrum:%subaccount:BTC,BTC,%value_without_fee,USD,%fiat_value,%label
|
||||
# NOTE: fiat_value must be manually updated in custom rules if your given cost-basis will be different
|
||||
& %ln_amount [1-9]
|
||||
comment ln_hash:%ln_hash, notes:%label, direction:%direction, taxed_as:GIFTIN
|
||||
comment2 %timestamp,GIFTIN,electrum:%subaccount:BTC,BTC,%ln_amount,USD,%fiat_value,%label
|
||||
|
||||
#
|
||||
# OUT
|
||||
#
|
||||
|
||||
if %direction ^OUT$
|
||||
amount -%oc_amount BTC
|
||||
account2 expenses:electrum:%subaccount:BTC
|
||||
comment txid:%txid, notes:%label, taxed_as:SPEND
|
||||
comment2 %timestamp,SPEND,electrum:%subaccount:BTC,BTC,%value_without_fee,USD,%fiat_value,%label
|
||||
comment txid:%oc_hash, notes:%label, taxed_as:SPEND
|
||||
comment2 %timestamp,SPEND,electrum:%subaccount:BTC,BTC,%oc_amount,USD,%fiat_value,%label
|
||||
|
||||
if %direction ^OUT$
|
||||
& %label (Self|Equity transfer|Capital contribution)
|
||||
account2 equity:electrum:%subaccount:deposit:BTC
|
||||
comment txid:%txid, notes:%label, direction:%direction
|
||||
comment2
|
||||
# NOTE: custom rule equity transfers should also clear comment2
|
||||
& %ln_amount [1-9]
|
||||
comment txid:%oc_hash, ln_hash:%ln_hash, notes:%label, direction:%direction, taxed_as:SPEND
|
||||
comment2 %timestamp,SPEND,electrum:%subaccount:BTC,BTC,%ln_amount,USD,%fiat_value,%label
|
||||
|
||||
if %direction ^OUT$
|
||||
& %oc_amount ^[^1-9]*$
|
||||
& %ln_amount [1-9]
|
||||
amount -%ln_amount BTC
|
||||
amount2 %ln_amount BTC
|
||||
|
||||
# Label: lightning channels
|
||||
|
||||
if %direction ^OUT$
|
||||
& %label ^Open channel
|
||||
& %oc_amount [1-9]
|
||||
& %ln_amount [1-9]
|
||||
amount -%ln_amount BTC
|
||||
account2 assets:electrum:%subaccount:ln_locked_payable:BTC
|
||||
comment2
|
||||
|
||||
if %direction ^OUT$
|
||||
& %label (^sweep local_anchor|^sweep our_ctx_to_local)
|
||||
& %oc_amount [1-9]
|
||||
& %ln_amount ^[^1-9]*$
|
||||
account2 assets:electrum:%subaccount:BTC
|
||||
comment
|
||||
comment2
|
||||
|
||||
# Treat this OUT as an IN as it's unlocking
|
||||
if %direction ^OUT$
|
||||
& %label ^Close channel
|
||||
& %oc_hash ^[^a-z0-9]*$
|
||||
& %ln_hash ^[^a-z0-9]*$
|
||||
& %oc_amount ^[^1-9]*$
|
||||
& %ln_amount [1-9]
|
||||
amount1 -%ln_amount BTC
|
||||
account1 assets:electrum:%subaccount:ln_locked_payable:BTC
|
||||
amount2 %ln_amount BTC
|
||||
account2 assets:electrum:%subaccount:BTC
|
||||
comment notes:%label, direction:%direction
|
||||
comment2
|
||||
|
||||
if %direction ^OUT$
|
||||
& %label ^Close channel
|
||||
& %oc_amount [1-9]
|
||||
& %ln_amount [1-9]
|
||||
amount1 -%ln_amount BTC
|
||||
account1 assets:electrum:%subaccount:ln_locked_payable:BTC
|
||||
amount2 %ln_amount BTC
|
||||
account2 assets:electrum:%subaccount:BTC
|
||||
comment2
|
||||
|
||||
# Label: transfers
|
||||
# NOTE: custom rule equity transfers should also clear comment2
|
||||
if %direction ^OUT$
|
||||
& %label (Self|Transfer|Equity transfer|Capital contribution)
|
||||
account2 equity:electrum:%subaccount:deposit:BTC
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction
|
||||
comment2
|
||||
|
||||
if %direction ^OUT$
|
||||
& %label (Self|Transfer|Equity transfer|Capital contribution)
|
||||
& %ln_amount [1-9]
|
||||
comment txid:%oc_hash, ln_hash:%ln_hash, notes:%label, direction:%direction
|
||||
|
||||
# Label: gifts
|
||||
# TODO: add regex for donate/donation
|
||||
# TODO: separate donations from gifts subaccount
|
||||
if %direction ^OUT$
|
||||
& %label Gift
|
||||
account2 expenses:electrum:%subaccount:gifts:BTC
|
||||
comment txid:%txid, notes:%label, direction:%direction, taxed_as:GIFT
|
||||
comment2 %timestamp,GIFT,electrum:%subaccount:BTC,BTC,%value_without_fee,USD,%fiat_value,%label
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction, taxed_as:GIFT
|
||||
comment2 %timestamp,GIFT,electrum:%subaccount:BTC,BTC,%oc_amount,USD,%fiat_value,%label
|
||||
|
||||
# Fees
|
||||
if %direction ^OUT$
|
||||
& %fee [1-9]
|
||||
& %label Gift
|
||||
& %ln_amount [1-9]
|
||||
comment txid:%oc_hash, ln_hash:%ln_hash, notes:%label, direction:%direction, taxed_as:GIFT
|
||||
comment2 %timestamp,GIFT,electrum:%subaccount:BTC,BTC,%ln_amount,USD,%fiat_value,%label
|
||||
|
||||
#
|
||||
# Fees
|
||||
#
|
||||
|
||||
if %direction ^OUT$
|
||||
& %network_fee [1-9]
|
||||
account3 assets:electrum:%subaccount:BTC
|
||||
amount3 -%fee BTC
|
||||
amount3 -%network_fee BTC
|
||||
account4 expenses:electrum:%subaccount:fees:BTC
|
||||
amount4 %fee BTC
|
||||
comment txid:%txid, notes:%label, direction:%direction, taxed_as:SPEND
|
||||
comment3 %timestamp,SPEND,electrum:%subaccount:BTC,BTC,%fee,USD,%fiat_fee,FEE
|
||||
amount4 %network_fee BTC
|
||||
comment txid:%oc_hash, notes:%label, direction:%direction, taxed_as:SPEND
|
||||
comment3 %timestamp,SPEND,electrum:%subaccount:BTC,BTC,%network_fee,USD,%fiat_fee,FEE
|
||||
# Using comment3 so a comment2 SPEND isn't overwritten (when applicable)
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
|
||||
Reference in New Issue
Block a user